using System.Collections.Generic;
using System.Threading.Tasks;
namespace PhoenixLib.DAL.EFCore.PGSQL
{
///
/// GenericAsyncMappedRepository is an asynchronous Data Access Object
///
///
///
public sealed class GenericMappedIntRepository : IGenericAsyncIntRepository
where TDto : class, IIntDto, new()
where TEntity : class, IIntEntity, new()
{
private readonly IMapper _mapper;
private readonly IGenericAsyncIntRepository _repository;
public GenericMappedIntRepository(IMapper mapper, IGenericAsyncIntRepository repository)
{
_mapper = mapper;
_repository = repository;
}
public async Task> GetAllAsync() => _mapper.Map(await _repository.GetAllAsync());
public async Task GetByIdAsync(int 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(int id)
{
await _repository.DeleteByIdAsync(id);
}
public async Task DeleteByIdsAsync(IEnumerable ids)
{
await _repository.DeleteByIdsAsync(ids);
}
}
}