public async Task <Pagination <ToDoResponse> > Handle(GetToDoListQuery request, CancellationToken cancellationToken) { var spec = new ToDoSpec(request); var countSpec = new ToDoWithFiltersForCountSpec(request); var totalItems = await _toDoRepository.CountAsync(countSpec); var todo = await _toDoRepository.ListWithSpecAsync(spec); var data = _mapper.Map <IReadOnlyList <Domain.Entities.ToDo>, IReadOnlyList <ToDoResponse> >(todo); return(new Pagination <ToDoResponse>(request.PageIndex, request.PageSize, totalItems, data)); }
public async Task <ToDoResponse> Handle(GetToDobyIdWithQuery request, CancellationToken cancellationToken) { var spec = new ToDoSpec(request.Id); var data = await _toDoRepository.GetEntityWithSpec(spec); if (data == null) { throw new NotFoundException(nameof(Domain.Entities.ToDo), request.Id); } _logger.LogInformation($"Succesfully Gets ToDo: {request.Id}"); return(_mapper.Map <ToDoResponse>(data)); }