using System.Collections.Generic; using System.Threading.Tasks; namespace PhoenixLib.DAL.EFCore.PGSQL { /// /// GenericAsyncMappedRepository is an asynchronous Data Access Object /// /// /// public sealed class GenericMappedLongRepository : IGenericAsyncLongRepository where TDto : class, ILongDto, new() where TEntity : class, ILongEntity, new() { private readonly IMapper _mapper; private readonly IGenericAsyncLongRepository _repository; public GenericMappedLongRepository(IMapper mapper, IGenericAsyncLongRepository repository) { _mapper = mapper; _repository = repository; } public async Task> GetAllAsync() => _mapper.Map(await _repository.GetAllAsync()); public async Task GetByIdAsync(long id) => _mapper.Map(await _repository.GetByIdAsync(id)); public async Task> GetByIdsAsync(IEnumerable ids) => _mapper.Map(await _repository.GetByIdsAsync(ids)); public async Task SaveAsync(TDto obj) => _mapper.Map(await _repository.SaveAsync(_mapper.Map(obj))); public async Task> SaveAsync(IReadOnlyList objs) => _mapper.Map(await _repository.SaveAsync(_mapper.Map(objs))); public async Task DeleteByIdAsync(long id) { await _repository.DeleteByIdAsync(id); } public async Task DeleteByIdsAsync(IEnumerable ids) { await _repository.DeleteByIdsAsync(ids); } } }