public ActionResult Album(int id) { var album = _albumService.GetOne(id); var childs = _albumService.GetAll().Where(x => x.ParentId == id); if (childs.Count() > 0) { var model = new GalleryViewModel() { Albums = childs.Select(x => new GalleryAlbumModel() { Id = x.Id, Title = CultureHelper.IsEnCulture() ? x.TitleEng : x.TitleRu, Description = CultureHelper.IsEnCulture() ? x.DescriptionEng : x.DescriptionRu, Cover = _albumService.GetAll().GetAlbumCover(x) }), ParentAlbums = _albumService.GetAll().BuildGraph(album) }; return(View("~/Views/Gallery/Index.cshtml", model)); } else { var photos = _photoService.GetAll().Where(x => x.AlbumId == id).ToList(); if (photos.Count() > 0) { var model = new GalleryPhotoListModel() { AlbumTitle = CultureHelper.IsEnCulture() ? album.TitleEng : album.TitleRu, Photos = photos.OrderByDescending(x => x.Order).Select(x => new GalleryPhotoModel() { Id = x.Id, Title = CultureHelper.IsEnCulture() ? x.TitleEng : x.TitleRu, Thumbnail = x.ThumbnailPath, Photo = x.PhotoPath, Description = CultureHelper.IsEnCulture() ? x.DescriptionEng : x.DescriptionRu, }), Albums = _albumService.GetAll().BuildGraph(album) }; return(View($"~/Views/Gallery/AlbumRenderPattern{(album.ViewPattern == default(int) ? 1 : album.ViewPattern)}.cshtml", model)); } else { return(View($"~/Views/Gallery/AlbumRenderPattern1.cshtml", new GalleryPhotoListModel())); } } }
public ActionResult Album(int id) { var album = _albumService.GetOne(id); var childs = _albumService.GetAll().Where(x => x.ParentId == id); if (childs.Count() > 0) { var model = new GalleryViewModel() { Albums = childs.Select(x => new GalleryAlbumModel() { Id = x.Id, TitleRu = x.TitleRu, TitleEng = x.TitleEng, Cover = x.CoverPath }) }; return(View("~/Views/Gallery/Index.cshtml", model)); } else { var photos = _photoService.GetAll().Where(x => x.AlbumId == id).ToList(); if (photos.Count() > 0) { var model = new GalleryPhotoListModel() { AlbumTitle = CultureHelper.IsEnCulture() ? album.TitleEng : album.TitleRu, Photos = photos.Select(x => new GalleryPhotoModel() { Id = x.Id, Thumbnail = x.ThumbnailPath, Photo = x.PhotoPath, Description = CultureHelper.IsEnCulture() ? x.DescriptionEng : x.DescriptionRu, }) }; return(View($"~/Views/Gallery/AlbumRenderPattern{album.ViewPattern ?? 1}.cshtml", model)); } else { return(View(new GalleryPhotoListModel())); } } }