|
123456789101112131415161718192021222324252627282930313233343536373839404142 |
- using Diligent.WebAPI.Business.Interfaces;
- using Diligent.WebAPI.Data;
- using MongoDB.Driver;
-
- namespace Diligent.WebAPI.Business.Services
- {
- public class BaseRepository<TEntity> : IBaseRepository<TEntity> where TEntity : class
- {
- protected readonly IMongoDBContext _mongoContext;
- protected IMongoCollection<TEntity> _dbCollection;
- public BaseRepository(IMongoDBContext context)
- {
- _mongoContext = context;
- _dbCollection = _mongoContext.GetCollection<TEntity>(typeof(TEntity).Name);
- }
-
- public Task CreateAsync(TEntity entity)
- {
- throw new NotImplementedException();
- }
-
- public async Task<List<TEntity>> GetAsync()
- {
- var all = await _dbCollection.FindAsync(Builders<TEntity>.Filter.Empty);
- return await all.ToListAsync();
- }
- public Task<TEntity> GetByIdAsync(string id)
- {
- throw new NotImplementedException();
- }
-
- public Task RemoveAsync(string id)
- {
- throw new NotImplementedException();
- }
-
- public Task UpdateAsync(string id, TEntity updateEntity)
- {
- throw new NotImplementedException();
- }
- }
- }
|