public ActionResult Edit(int id)
        {
            var gallery = _galleryService.GetGalleryById(id);

            if (gallery == null)
            {
                //No gallery found with the specified id
                return(RedirectToAction("List"));
            }

            var model = gallery.ToModel();

            if (_gallerySettings.SliderGallery)
            {
                model.SliderGallery = true;
            }
            if (gallery.SimpleGallery)
            {
                model.GalleryType = "SimpleGallery";
            }
            if (gallery.FlickrGallery)
            {
                model.GalleryType = "FlickrGallery";
            }
            if (gallery.PicasaGallery)
            {
                model.GalleryType = "PicasaGallery";
            }
            if (gallery.VideoGallery)
            {
                model.GalleryType = "VideoGallery";
            }


            //locales
            AddLocales(_languageService, model.Locales, (locale, languageId) =>
            {
                locale.Name        = gallery.GetLocalized(x => x.Name, languageId, false, false);
                locale.Description = gallery.GetLocalized(x => x.Description, languageId, false, false);
            });
            if (gallery.VideoLink != null)
            {
                var videoLinks = gallery.VideoLink.Split(new[] { "%,%" }, StringSplitOptions.None).ToList();
                var i          = 1;
                foreach (var vl in videoLinks)
                {
                    model.VideoLinks.Add(new SelectListItem {
                        Text = vl, Value = i.ToString()
                    });
                    i++;
                }
            }

            return(View("~/Plugins/Widgets.Gallery/Views/GalleryConfigure/Edit.cshtml", model));
        }
示例#2
0
        public async Task <JsonResult> GetItem(int Id)
        {
            var result = svs.GetGalleryById(Id, _appSettings.App_Identity.Identity);

            return(new JsonResult(result, new JsonSerializerSettings()
            {
                ReferenceLoopHandling = ReferenceLoopHandling.Ignore
            }));
        }
 public IActionResult GetGalleryById([FromQuery] Guid galleryId)
 {
     try
     {
         var gallery = _galleryService.GetGalleryById(galleryId);
         return(Ok(gallery));
     }
     catch (Exception ex)
     {
         _logger.LogError("Error", ex);
         return(BadRequest());
     }
 }
示例#4
0
        public ActionResult Gallery(int id, int page = 1)
        {
            if (page == 0)
            {
                return(RedirectToAction("PageNotFound", "Common"));
            }
            ViewBag.GalleryId = id;
            var model = new PublicInfoGalleryModel();

            model.ShowGallery = _gallerySettings.ShowGalleries;
            if (!_gallerySettings.SliderGallery)
            {
                var images = _galleryService.GetGalleryImagesPagesByGalleryId(id, page, _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
                    (View("~/Plugins/Widgets.Gallery/Views/GalleryPublicInfo/List.cshtml", model));
            }
            else
            {
                var gallery = _galleryService.GetGalleryById(id);
                if (gallery.SimpleGallery)
                {
                    var images = _galleryService.GetGalleryImagesByGalleryId(id);
                    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
                        (View("~/Plugins/Widgets.Gallery/Views/GalleryPublicInfo/GalleriaList.cshtml", model));
                }
                if (gallery.FlickrGallery)
                {
                    ViewBag.FlickrKeysords = gallery.FlickrKeyword;
                    return(View("~/Plugins/Widgets.Gallery/Views/GalleryPublicInfo/FlickrList.cshtml"));
                }
                if (gallery.PicasaGallery)
                {
                    ViewBag.PicasaKeyword = gallery.PicasaKeyword;
                    return(View("~/Plugins/Widgets.Gallery/Views/GalleryPublicInfo/PicasaList.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/VideoList.cshtml", videoLinks));
                }
                return(null);
            }
        }