public static IQueryable <GalleryItem> GetGalleryItemsHavingTags(string[] tags, string[] people, int galleryId, MetadataItemName sortByMetaName, bool sortAscending) { IAlbum album = GetGalleryObjectsHavingTags(tags, people, galleryId); IList <IGalleryObject> galleryObjects; if (MetadataItemNameEnumHelper.IsValidFormattedMetadataItemName(sortByMetaName)) { galleryObjects = album.GetChildGalleryObjects(GalleryObjectType.All, !Utils.IsAuthenticated).ToSortedList(sortByMetaName, sortAscending, album.GalleryId); } else { galleryObjects = album.GetChildGalleryObjects(GalleryObjectType.All, !Utils.IsAuthenticated).ToSortedList(); } return(ToGalleryItems(galleryObjects).AsQueryable()); }
/// <summary> /// Gets the gallery objects in the album. Includes albums and media objects. /// </summary> /// <param name="albumId">The album ID.</param> /// <param name="sortByMetaName">The sort by meta name id.</param> /// <param name="sortAscending">if set to <c>true</c> [sort ascending].</param> /// <returns>Returns an <see cref="IQueryable" /> instance of <see cref="Entity.GalleryItem" />.</returns> /// <exception cref="InvalidAlbumException">Thrown when an album with the specified /// <paramref name="albumId" /> is not found in the data store.</exception> /// <exception cref="GalleryServerPro.Events.CustomExceptions.GallerySecurityException">Thrown when the user does not have at least one of the requested permissions to the /// specified album.</exception> public static IQueryable <GalleryItem> GetGalleryItemsInAlbum(int albumId, MetadataItemName sortByMetaName, bool sortAscending) { IAlbum album = Factory.LoadAlbumInstance(albumId, true); SecurityManager.ThrowIfUserNotAuthorized(SecurityActions.ViewAlbumOrMediaObject, RoleController.GetGalleryServerRolesForUser(), album.Id, album.GalleryId, Utils.IsAuthenticated, album.IsPrivate, album.IsVirtualAlbum); IList <IGalleryObject> galleryObjects; if (MetadataItemNameEnumHelper.IsValidFormattedMetadataItemName(sortByMetaName)) { galleryObjects = album.GetChildGalleryObjects(GalleryObjectType.All, !Utils.IsAuthenticated).ToSortedList(sortByMetaName, sortAscending, album.GalleryId); } else { galleryObjects = album.GetChildGalleryObjects(GalleryObjectType.All, !Utils.IsAuthenticated).ToSortedList(); } return(ToGalleryItems(galleryObjects).AsQueryable()); }
public async Task <IActionResult> RebuildItemForGallery(int metaNameId, int galleryId) { try { if (await _userController.IsCurrentUserGalleryAdministrator(galleryId)) { var metaName = (MetadataItemName)metaNameId; if (MetadataItemNameEnumHelper.IsValidFormattedMetadataItemName(metaName)) { _metadataController.RebuildItemForGalleryAsync(metaName, galleryId); } } return(Ok()); } catch (Exception ex) { AppEventController.LogError(ex); return(StatusCode(500, _exController.GetExString(ex))); } }
public void RebuildItemForGallery(int metaNameId, int galleryId) { try { if (Utils.IsCurrentUserGalleryAdministrator(galleryId)) { var metaName = (MetadataItemName)metaNameId; if (MetadataItemNameEnumHelper.IsValidFormattedMetadataItemName(metaName)) { MetadataController.RebuildItemForGalleryAsync(metaName, galleryId); } } } catch (Exception ex) { AppEventController.LogError(ex); throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.InternalServerError) { Content = Utils.GetExStringContent(ex), ReasonPhrase = "Server Error" }); } }