Esempio n. 1
0
        public async Task <IActionResult> GetAll(
            [FromQuery] string filter = null,
            [FromQuery] int?page      = 1,
            [FromQuery] int?pageSize  = 10,
            CancellationToken ct      = default)
        {
            if (pageSize > ApiLimits.MaxResultsPerCall)
            {
                return(new ObjectResult($"No more than {ApiLimits.MaxResultsPerCall} results per page")
                {
                    StatusCode = (int)HttpStatusCode.ExpectationFailed
                });
            }

            (IReadOnlyEmployee[] Employees, int Total)filterResult = await _employeesRepository.GetAllPaging(filter, page, pageSize, ct);

            return(Ok(new GetAllEmployeesResult
            {
                Total = filterResult.Total,
                Employees = filterResult.Employees.Select(x => EmployeeSummary.Load(x, _getUtcNow))
            }));
        }