using Dpz.Core.Public.ViewModel.Request;
using Dpz.Core.Public.ViewModel.Response;
namespace Dpz.Core.Service.RepositoryServiceImpl;
public class EmailHistoryService(IRepository<EmailHistory> repository, IMapper mapper)
: IEmailHistoryService
{
public async Task AddAsync(AddEmailHistoryRequest request)
{
var entity = mapper.Map<EmailHistory>(request);
await repository.InsertAsync(entity);
}
public async Task<IPagedList<EmailHistoryResponse>> GetHistoriesAsync(
int pageIndex = 1,
int pageSize = 20
)
{
return await repository
.MongodbQueryable.OrderByDescending(x => x.Id)
.ToPagedListAsync<EmailHistory, EmailHistoryResponse>(pageIndex, pageSize);
}
}