Beispiel #1
0
        public async Task <IActionResult> Get([FromQuery] GetAllPatientQuery getAllPatientQuery)
        {
            var response = await _mediator.Send(getAllPatientQuery);

            if (response.Errors.Any())
            {
                return(BadRequest(new { Errors = response.Errors }));
            }

            var paginationFilter = getAllPatientQuery == null ? new PaginationFilter() : PaginationFilter.Initialize(getAllPatientQuery.PageNumber, getAllPatientQuery.PageSize);

            var result = PagedResponse.CreatePaginatedResponse(_absoluteUrl, paginationFilter, response.HasData ? response.Result : null);

            return(Ok(result));
        }
Beispiel #2
0
        protected override Result <PagedResponse <ApplicationDto> > Handle(GetAuditApplicationsQuery request)
        {
            _logger.LogInformation(
                "----- Handling query: {RequestName} - ({@Request})",
                request.GetGenericTypeName(),
                request);

            var pagination = _mapper.Map <PaginationDetails>(request).WithTotal(_dbContext.AuditApplications.Count())
                             .WithApiRoute(ApiRoutes.AuditApplications.GetAll);

            var auditApps = _mapper.ProjectTo <ApplicationDto>(_dbContext.AuditApplications.OrderBy(a => a.Id))
                            .Skip(pagination.PreviousPageNumber * pagination.PageSize)
                            .Take(request.PageSize).ToList();

            var paginationResponse = PagedResponse <ApplicationDto> .CreatePaginatedResponse(_uriService, pagination, auditApps);

            return(Result.Ok(paginationResponse));
        }
Beispiel #3
0
        protected override Result <PagedResponse <AuditDto> > Handle(SearchAuditsQuery request)
        {
            _logger.LogInformation(
                "----- Handling query: {RequestName} - ({@Request})",
                request.GetGenericTypeName(),
                request);

            var pagination = _mapper.Map <PaginationDetails>(request).WithTotal(_dbContext.Audits.Count());

            var skip = (request.PageNumber) * request.PageSize;

            var audits = _mapper.ProjectTo <AuditDto>(_dbContext.Audits)
                         .Where(a => string.IsNullOrEmpty(request.DescriptionContains) || a.Description.Contains(request.DescriptionContains))
                         .Where(a => string.IsNullOrEmpty(request.PropertiesContains) || a.Properties.Contains(request.PropertiesContains))
                         .OrderBy(a => a.Id)
                         .Skip(pagination.PreviousPageNumber * pagination.PageSize).ToList();

            var paginationResponse = PagedResponse <AuditDto> .CreatePaginatedResponse(_uriService, pagination, audits);

            return(Result.Ok(paginationResponse));
        }