public Entity.GalleryData GetInflatedAlbum(int id, int top = 0, int skip = 0) { // GET /api/albums/12/inflated // Return data for album # 12 IAlbum album = null; try { album = Factory.LoadAlbumInstance(new AlbumLoadOptions(id) { InflateChildObjects = true }); var loadOptions = new Entity.GalleryDataLoadOptions { LoadGalleryItems = true, NumGalleryItemsToRetrieve = top, NumGalleryItemsToSkip = skip }; return(GalleryController.GetGalleryDataForAlbum(album, loadOptions)); } catch (InvalidAlbumException) { throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.NotFound) { Content = new StringContent(String.Format("Could not find album with ID = {0}", id)), ReasonPhrase = "Album Not Found" }); } catch (GallerySecurityException ex) { AppEventController.LogError(ex); throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.Forbidden)); } catch (Exception ex) { AppEventController.LogError(ex, (album != null ? album.GalleryId : new int?())); throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.InternalServerError) { Content = Utils.GetExStringContent(ex), ReasonPhrase = "Server Error" }); } }
public async Task <IActionResult> GetInflatedAlbum(int id, int top = 0, int skip = 0) { // GET /api/albums/inflated/12 // Return data for album # 12 IAlbum album = null; try { album = Factory.LoadAlbumInstance(new AlbumLoadOptions(id) { InflateChildObjects = true }); var loadOptions = new Entity.GalleryDataLoadOptions { LoadGalleryItems = true, NumGalleryItemsToRetrieve = top, NumGalleryItemsToSkip = skip }; SecurityManager.ThrowIfUserNotAuthorized(SecurityActions.ViewAlbumOrMediaObject, await _userController.GetGalleryServerRolesForUser(), album.Id, album.GalleryId, _userController.IsAuthenticated, album.IsPrivate, album.IsVirtualAlbum); return(new JsonResult(await _albumController.GetGalleryDataForAlbum(album, loadOptions))); } catch (InvalidAlbumException) { return(NotFound($"Could not find album with ID {id}.")); } catch (GallerySecurityException ex) { AppEventController.LogError(ex); return(Forbid()); } catch (Exception ex) { AppEventController.LogError(ex, album?.GalleryId); return(StatusCode(500, _exController.GetExString(ex))); } }
public Entity.GalleryData GetInflatedAlbum(int id, int top = 0, int skip = 0) { // GET /api/albums/12/inflated // Return data for album # 12 IAlbum album = null; try { album = Factory.LoadAlbumInstance(id, true); var loadOptions = new Entity.GalleryDataLoadOptions { LoadGalleryItems = true, NumGalleryItemsToRetrieve = top, NumGalleryItemsToSkip = skip }; return GalleryController.GetGalleryDataForAlbum(album, loadOptions); } catch (InvalidAlbumException) { throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.NotFound) { Content = new StringContent(String.Format("Could not find album with ID = {0}", id)), ReasonPhrase = "Album Not Found" }); } catch (GallerySecurityException) { throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.Forbidden)); } catch (Exception ex) { AppEventController.LogError(ex, (album != null ? album.GalleryId : new int?())); throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.InternalServerError) { Content = Utils.GetExStringContent(ex), ReasonPhrase = "Server Error" }); } }