Exemple #1
0
 public IActionResult GetStorageSites(
     [FromQuery] bool getAll         = false,
     [FromQuery] int page            = 1,
     [FromQuery] int elementsPerPage = 10,
     [FromQuery] string search       = null)
 {
     try
     {
         IEnumerable <StorageSite> sites = null;
         if (string.IsNullOrWhiteSpace(search))
         {
             sites = LocationsService.GetAllStorageSites();
         }
         else
         {
             sites = LocationsService.SearchStorageSitesByName(search);
         }
         IEnumerable <StorageSite> paginatedSites = sites;
         if (!getAll)
         {
             paginatedSites = sites.Skip((page - 1) * elementsPerPage).Take(elementsPerPage);
         }
         return(Ok(new PaginatedResponse(paginatedSites, sites.Count())));
     }
     catch (Exception exception)
     {
         return(HandleUnexpectedException(exception));
     }
 }