public List <FishPhoto> GetAquariumFishPhotos(int aquariumId, PaginationSliver pagination) { var photos = _aquariumDao.GetAquariumFishPhotos(aquariumId); if (pagination.Descending) { photos = photos.OrderByDescending(p => p.Photo.Date); } var sliver = photos.Skip(pagination.Start).Take(pagination.Count); return(sliver.ToList()); }
public List <AquariumSnapshot> GetAquariumSnapshotPhotos(int aquariumId, PaginationSliver pagination) { var photos = _aquariumDao.GetSnapshotsByAquarium(aquariumId) .Where(s => s.Photo != null); if (pagination.Descending) { photos = photos.OrderByDescending(p => p.Photo.Date); } var sliver = photos.Skip(pagination.Start).Take(pagination.Count); return(sliver.ToList()); }
public IActionResult GetAquariumFishPhotos(int aquariumId, [FromBody] PaginationSliver pagination) { try { _logger.LogInformation($"GET /v1/Photo/Aquarium/{aquariumId}/Fish called"); var id = _accountService.GetCurrentUserId(); var aq = _aquariumService.GetAquariumById(aquariumId); if (aq.OwnerId != id) { return(new UnauthorizedResult()); } var aquariumPhotos = _aquariumService.GetAquariumFishPhotos(aquariumId, pagination); return(new OkObjectResult(aquariumPhotos)); } catch (Exception ex) { _logger.LogError($"GET /v1/Photo/Aquarium/{aquariumId}/Fish endpoint caught exception: { ex.Message } Details: { ex.ToString() }"); return(NotFound()); } }
public IActionResult GetDeviceATOHistory(int deviceId, [FromBody] PaginationSliver pagination = null) { if (!ValidateRequest(deviceId)) { return(Unauthorized()); } if (pagination == null) { pagination = new PaginationSliver(); } try { _logger.LogInformation($"GET /v1/Device/{deviceId}/ATO/History called"); List <ATOStatus> atoHistory = _aquariumService.GetDeviceATOHistory(deviceId, pagination); return(new OkObjectResult(atoHistory)); } catch (Exception ex) { _logger.LogError($"GET /v1/Device/{deviceId}/ATO/History endpoint caught exception: { ex.Message } Details: { ex.ToString() }"); return(NotFound()); } }
public List <ATOStatus> GetDeviceATOHistory(int deviceId, PaginationSliver paginationSliver) { return(_aquariumDao.GetATOHistory(deviceId, paginationSliver)); }