public static PublicInfoGalleryModel ToModel(this Galleries entity) { if (entity == null) { return(null); } var model = new PublicInfoGalleryModel { Id = entity.Id, GalleryName = entity.GetLocalized(x => x.Name), GalleryDescription = entity.GetLocalized(x => x.Description), }; return(model); }
public ActionResult WidgetGallery(int page = 1) { int id; if (page == 0) { return(RedirectToAction("PageNotFound", "Common")); } var model = new PublicInfoGalleryModel(); if (!_gallerySettings.SliderGallery) { List <GalleryImages> images; if (!Int32.TryParse(_gallerySettings.GalleryWidgetName, out id)) { images = _galleryService.GetGalleryImagesPages(page, _gallerySettings.ItemPerWidgetPage < 1 ? 1 : _gallerySettings.ItemPerWidgetPage).ToList(); } else if (id == -1) { images = _galleryService.GetGalleryImagesPages(page, _gallerySettings.ItemPerWidgetPage < 1 ? 1 : _gallerySettings.ItemPerWidgetPage).ToList(); } else { images = _galleryService.GetGalleryImagesByGalleryId(id).ToList(); } ViewBag.GalleryId = id; foreach (var image in images) { var alt = image.GetLocalized(x => x.Description) != null ? image.GetLocalized(x => x.Description).Replace("<p>", "").Replace("</p>", "") : ""; if (model.ImageGalleryPictureModel.Count < _gallerySettings.ItemPerWidgetPage) { model.ImageModel.Add(new ImageModel { ShareImage = _gallerySettings.ShareImage, Id = image.Id, ImageGalleryPictureModel = new PictureModel { FullSizeImageUrl = _pictureService.GetPictureUrl(image.PictureId), ImageUrl = _pictureService.GetPictureUrl(image.PictureId, GalleryThumbPictureSize), Title = image.GetLocalized(x => x.Name), AlternateText = alt, } }); } } return (View("~/Plugins/Widgets.Gallery/Views/GalleryPublicInfo/WidgetList.cshtml", model)); } else { List <GalleryImages> images; if (!Int32.TryParse(_gallerySettings.GalleryWidgetName, out id)) { images = _galleryService.GetGalleryImagesPages(page, _gallerySettings.ItemPerWidgetPage < 1 ? 1 : _gallerySettings.ItemPerWidgetPage).ToList(); } else if (id == -1) { images = _galleryService.GetGalleryImagesPages(page, _gallerySettings.ItemPerWidgetPage < 1 ? 1 : _gallerySettings.ItemPerWidgetPage).ToList(); foreach (var image in images) { var alt = image.GetLocalized(x => x.Description) != null ? image.GetLocalized(x => x.Description).Replace("<p>", "").Replace("</p>", "") : ""; model.ImageModel.Add(new ImageModel { ShareImage = _gallerySettings.ShareImage, ImageGalleryPictureModel = new PictureModel { FullSizeImageUrl = _pictureService.GetPictureUrl(image.PictureId), ImageUrl = _pictureService.GetPictureUrl(image.PictureId, GalleryThumbPictureSize), Title = image.GetLocalized(x => x.Name), AlternateText = alt, } }); } return (View("~/Plugins/Widgets.Gallery/Views/GalleryPublicInfo/WidgetGalleriaList.cshtml", model)); } else { images = _galleryService.GetGalleryImagesByGalleryId(id).ToList(); } var gallery = _galleryService.GetGalleryById(id); if (gallery.SimpleGallery) { foreach (var image in images) { var alt = image.GetLocalized(x => x.Description) != null ? image.GetLocalized(x => x.Description).Replace("<p>", "").Replace("</p>", "") : ""; model.ImageModel.Add(new ImageModel { ShareImage = _gallerySettings.ShareImage, ImageGalleryPictureModel = new PictureModel { FullSizeImageUrl = _pictureService.GetPictureUrl(image.PictureId), ImageUrl = _pictureService.GetPictureUrl(image.PictureId, GalleryThumbPictureSize), Title = image.GetLocalized(x => x.Name), AlternateText = alt, } }); } return (View("~/Plugins/Widgets.Gallery/Views/GalleryPublicInfo/WidgetGalleriaList.cshtml", model)); } if (gallery.FlickrGallery) { ViewBag.FlickrKeysords = gallery.FlickrKeyword; return(View("~/Plugins/Widgets.Gallery/Views/GalleryPublicInfo/WidgetFlickrList.cshtml")); } if (gallery.PicasaGallery) { ViewBag.PicasaKeyword = gallery.PicasaKeyword; return(View("~/Plugins/Widgets.Gallery/Views/GalleryPublicInfo/WidgetPicasaList.cshtml")); } if (gallery.VideoGallery) { var videoLinks = new List <string>(); if (gallery.VideoLink != null) { videoLinks = gallery.VideoLink.Split(new[] { "%,%" }, StringSplitOptions.None).ToList(); } return(View("~/Plugins/Widgets.Gallery/Views/GalleryPublicInfo/WidgetVideoList.cshtml", videoLinks)); } } return(null); }
public ActionResult List(int page = 1) { if (page == 0) { return(RedirectToAction("PageNotFound", "Common")); } var model = new PublicInfoGalleryModel(); model.ShowGallery = _gallerySettings.ShowGalleries; if (_gallerySettings.ShowGalleries) { var galleries = _galleryService.GetGalleryPages(page, _gallerySettings.ItemPerPage < 1 ? 1 : _gallerySettings.ItemPerPage); foreach (var gal in galleries) { var alt = gal.GetLocalized(x => x.Description) != null?gal.GetLocalized(x => x.Description).Replace("<p>", "").Replace("</p>", "") : ""; model.ImageGallery.Add(new ImageGalleryModel { Id = gal.Id, ImageGalleryPictureModel = new PictureModel { FullSizeImageUrl = _pictureService.GetPictureUrl(gal.PictureId), ImageUrl = _pictureService.GetPictureUrl(gal.PictureId, GalleryThumbPictureSize), Title = gal.GetLocalized(x => x.Name), AlternateText = alt, } }); } if (_gallerySettings.ShowImageAfterGalleries) { var count = Convert.ToInt32(Math.Ceiling(_galleryService.Counter(_gallerySettings.ItemPerPage < 1 ? 1 : _gallerySettings.ItemPerPage))); if (page >= count) { if (count == page) { page = 1; } if (count < page) { page = page - count + 1; } model.ShowImages = true; var imagesWithoutGallery = _galleryService.GetImagesPagesWithoutGallery(page, _gallerySettings.ItemPerPage < 1 ? 1 : _gallerySettings.ItemPerPage); foreach (var image in imagesWithoutGallery) { var alt = image.GetLocalized(x => x.Description) != null?image.GetLocalized(x => x.Description).Replace("<p>", "").Replace("</p>", "") : ""; model.ImageModel.Add(new ImageModel { ShareImage = _gallerySettings.ShareImage, Id = image.Id, ImageGalleryPictureModel = new PictureModel { FullSizeImageUrl = _pictureService.GetPictureUrl(image.PictureId), ImageUrl = _pictureService.GetPictureUrl(image.PictureId, GalleryThumbPictureSize), Title = image.GetLocalized(x => x.Name), AlternateText = alt, } }); } } return(Json(new { success = true, data = model, })); //return View("~/Plugins/Widgets.Gallery/Views/GalleryPublicInfo/GalleryWithAloneImages.cshtml", model); } return(Json(new { success = true, data = model, })); //return View("~/Plugins/Widgets.Gallery/Views/GalleryPublicInfo/GalleryList.cshtml", model); } var images = _galleryService.GetGalleryImagesPages(page, _gallerySettings.ItemPerPage < 1 ? 1 : _gallerySettings.ItemPerPage); foreach (var image in images) { var alt = image.GetLocalized(x => x.Description) != null?image.GetLocalized(x => x.Description).Replace("<p>", "").Replace("</p>", "") : ""; model.ImageModel.Add(new ImageModel { ShareImage = _gallerySettings.ShareImage, Id = image.Id, ImageGalleryPictureModel = new PictureModel { FullSizeImageUrl = _pictureService.GetPictureUrl(image.PictureId), ImageUrl = _pictureService.GetPictureUrl(image.PictureId, GalleryThumbPictureSize), Title = image.GetLocalized(x => x.Name), AlternateText = alt, } }); } return(Json(new { success = true, data = model, })); //return View(_gallerySettings.SliderGallery ? "~/Plugins/Widgets.Gallery/Views/GalleryPublicInfo/GalleriaList.cshtml" : "~/Plugins/Widgets.Gallery/Views/GalleryPublicInfo/List.cshtml.cshtml", model); }
public static Galleries ToEntity(this PublicInfoGalleryModel model, Galleries destination) { return(Mapper.Map(model, destination)); }
public static Galleries ToEntity(this PublicInfoGalleryModel model) { return(Mapper.Map <PublicInfoGalleryModel, Galleries>(model)); }