Exemplo n.º 1
0
        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());
        }
Exemplo n.º 2
0
        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));
        }