Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. using Diligent.WebAPI.Business.Interfaces;
  2. using Diligent.WebAPI.Data;
  3. using MongoDB.Driver;
  4. namespace Diligent.WebAPI.Business.Services
  5. {
  6. public class BaseRepository<TEntity> : IBaseRepository<TEntity> where TEntity : class
  7. {
  8. protected readonly IMongoDBContext _mongoContext;
  9. protected IMongoCollection<TEntity> _dbCollection;
  10. public BaseRepository(IMongoDBContext context)
  11. {
  12. _mongoContext = context;
  13. _dbCollection = _mongoContext.GetCollection<TEntity>(typeof(TEntity).Name);
  14. }
  15. public Task CreateAsync(TEntity entity)
  16. {
  17. throw new NotImplementedException();
  18. }
  19. public async Task<List<TEntity>> GetAsync()
  20. {
  21. var all = await _dbCollection.FindAsync(Builders<TEntity>.Filter.Empty);
  22. return await all.ToListAsync();
  23. }
  24. public Task<TEntity> GetByIdAsync(string id)
  25. {
  26. throw new NotImplementedException();
  27. }
  28. public Task RemoveAsync(string id)
  29. {
  30. throw new NotImplementedException();
  31. }
  32. public Task UpdateAsync(string id, TEntity updateEntity)
  33. {
  34. throw new NotImplementedException();
  35. }
  36. }
  37. }