public ActionResult <IQueryable <Department> > GetDepartments([FromQuery] string name, [FromQuery] APIRequestSize request) { var result = _context.Departments as IQueryable <Department>; Response.Headers["x-total-count"] = result.Count().ToString(); if (!string.IsNullOrEmpty(name)) { result = result.Where(d => d.Name.StartsWith(name, StringComparison.InvariantCultureIgnoreCase)); } if (request.Limit >= 100) { _logger.LogInformation("Requesting more thant 100 departments"); } return(Ok(result.OrderBy(d => d.DepartmentId).Skip(request.Offset).Take(request.Limit))); }
public ActionResult <IQueryable <Machine> > GetMachines([FromQuery] string name, [FromQuery] APIRequestSize requestSize) { var result = _context.Machines as IQueryable <Machine>; Response.Headers["x-total-count"] = result.Count().ToString(); if (!string.IsNullOrEmpty(name)) { result = result.Where(m => m.Name.StartsWith(name, StringComparison.InvariantCultureIgnoreCase)); } if (requestSize.Limit >= 100) { _logger.LogInformation("Requesting more thant 100 cost centers"); } return(Ok(result .OrderBy(p => p.Name).Skip(requestSize.Offset).Take(requestSize.Limit))); }
public async Task <ActionResult <IQueryable <PlantModel> > > GetPlants([FromQuery] string name, [FromQuery] APIRequestSize request) { var res = await _plantRepository.GetAllAsync(); Response.Headers["x-total-count"] = res.Count().ToString(); if (!string.IsNullOrEmpty(name)) { res = res.Where(p => p.Name.StartsWith(name, StringComparison.InvariantCultureIgnoreCase)); } if (request.Limit >= 100) { _logger.LogInformation("Requesting more thant 100 plants"); } //return Ok(); return(Ok(res.OrderBy(p => p.PlantId).Skip(request.Offset).Take(request.Limit))); }