public async Task <List <IncidentResource> > Handle(GetAllIncidentsQuery request, CancellationToken cancellationToken) { var incidents = await _dataContext.Incidents .Include(x => x.Updates) .Page(request.Page, request.Limit) .IncidentOrder() .AsNoTracking() .ToListAsync(cancellationToken); return(incidents.Select(IncidentResource.FromIncident).ToList()); }
public async Task <ActionResult <PagedResponse <IncidentResource> > > GetIncidentsAsync([FromQuery] GetAllIncidentsQuery incidentQuery) { var incidentResources = await _mediator.Send(incidentQuery); if (incidentResources == null) { return(NotFound()); } return(PageService.CreatePaginatedResponse(incidentQuery.Page, incidentQuery.Limit, incidentResources)); }