コード例 #1
0
        public async Task <OpenReddingPagedViewModel <EmployeeSalarySearchResultDto> > GetEmployeeSalaries(
            [FromQuery] string?name,
            [FromQuery] string?jobTitle,
            [FromQuery] string?agency,
            [FromQuery] string?status,
            [FromQuery] string?sortBy,
            [FromQuery] int?year,
            [FromQuery] int?basePayRange,
            [FromQuery] int?totalPayRange,
            [FromQuery] int?page,
            [FromQuery] string?sortField)
        {
            _logger.LogInformation($"Querying salaries:\n" +
                                   $"name [{name}]\n" +
                                   $"jobTitle [{jobTitle}]\n" +
                                   $"agency [{agency}]\n" +
                                   $"status [{status}]\n" +
                                   $"sortBy [{sortBy}]\n" +
                                   $"year [{year}]\n" +
                                   $"basePayRange [{basePayRange}]\n" +
                                   $"totalPayRange [{totalPayRange}]\n" +
                                   $"page [{page}]\n" +
                                   $"sortField [{sortField}]");

            _logger.LogInformation("Sending employee salary search request...");
            var searchRequest = new EmployeeSalarySearchRequestDto(name, jobTitle, agency, status, sortBy, year, sortField, basePayRange, totalPayRange);

            var response = await Mediator.Send(new GetEmployeeSalariesQuery(searchRequest, new Uri(_gatewayBaseUrl), page));

            _logger.LogInformation($"Request was successful, {response.Results.Count()} found with {response.Count} results");

            return(new OpenReddingPagedViewModel <EmployeeSalarySearchResultDto>
            {
                Results = response.Results,
                Count = response.Count,
                Pages = response.Pages,
                CurrentPage = response.CurrentPage,
                Links = _linkBuilder.BuildPaginationLinks(HttpContext.Request.Query, response.Pages, page)
            });
        }