Guest User

Untitled

a guest
Jan 19th, 2019
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.38 KB | None | 0 0
  1. public class ServiceBase<TEntity> : IServiceBase<TEntity> where TEntity : class, IIdentityEntity
  2. {
  3. protected readonly IRepositoryAsync<TEntity> repository;
  4.  
  5. public ServiceBase(IRepositoryAsync<TEntity> repository)
  6. {
  7. this.repository = repository;
  8. }
  9. public virtual async Task<TEntity> AddAsync(TEntity obj)
  10. {
  11. return await repository.AddAsync(obj);
  12. }
  13.  
  14. public virtual async Task AddRangeAsync(IEnumerable<TEntity> entities)
  15. {
  16. await repository.AddRangeAsync(entities);
  17. }
  18.  
  19. public virtual async Task<IEnumerable<TEntity>> GetAllAsync()
  20. {
  21. return await repository.GetAllAsync();
  22. }
  23.  
  24. public virtual async Task<TEntity> GetByIdAsync(object id)
  25. {
  26. return await repository.GetByIdAsync(id);
  27. }
  28.  
  29. public virtual async Task<bool> RemoveAsync(object id)
  30. {
  31. return await repository.RemoveAsync(id);
  32. }
  33.  
  34. public virtual async Task RemoveAsync(TEntity obj)
  35. {
  36. await repository.RemoveAsync(obj);
  37. }
  38.  
  39. public virtual async Task RemoveRangeAsync(IEnumerable<TEntity> entities)
  40. {
  41. await repository.RemoveRangeAsync(entities);
  42. }
  43.  
  44. public virtual async Task UpdateAsync(TEntity obj)
  45. {
  46. await repository.UpdateAsync(obj);
  47. }
  48.  
  49. public virtual async Task UpdateRangeAsync(IEnumerable<TEntity> entities)
  50. {
  51. await repository.UpdateRangeAsync(entities);
  52. }
  53. }
Add Comment
Please, Sign In to add comment