Example #1
0
        public async Task <ActionResult <IList <TaskLogEntry> > > GetTaskLogEntries(
            [FromQuery] SieveModel sieveModel
            )
        {
            // Validate the page size and page.
            if (sieveModel.PageSize < 1)
            {
                throw new ArgumentOutOfRangeException("Page size must be >= 1.");
            }
            if (sieveModel.Page < 1)
            {
                throw new ArgumentOutOfRangeException("Page must be >= 1.");
            }

            // Task log entry query.
            var taskLogEntries = context.TaskLogEntries
                                 .AsNoTracking()
                                 .Include(tle => tle.Task)
                                 .Include(tle => tle.TaskOutcome);

            var sievedTaskLogEntries = await SieveProcessor
                                       .GetPagedAsync(taskLogEntries, sieveModel);

            Response.Headers.Add("X-Pagination", sievedTaskLogEntries
                                 .SerializeMetadataToJson());

            return(Ok(sievedTaskLogEntries.Results));
        }
        public async Task <ActionResult <IList <Employee> > > GetEmployees(
            [FromQuery] SieveModel sieveModel
            )
        {
            // Validate the page size and page.
            if (sieveModel.PageSize < 1)
            {
                throw new ArgumentOutOfRangeException("Page size must be >= 1.");
            }
            if (sieveModel.Page < 1)
            {
                throw new ArgumentOutOfRangeException("Page must be >= 1.");
            }

            // Employee query.
            var employees = context.Employees
                            .AsNoTracking()
                            .Include(e => e.TimelineEntries);

            var sievedEmployees = await SieveProcessor
                                  .GetPagedAsync(employees, sieveModel);

            Response.Headers.Add("X-Pagination", sievedEmployees
                                 .SerializeMetadataToJson());

            return(Ok(sievedEmployees.Results));
        }