public ActionResult Create() { var model = new ConfigurationGalleryModel(); model.GalleryType = "SimpleGallery"; if (_gallerySettings.SliderGallery) { model.SliderGallery = true; } //locales AddLocales(_languageService, model.Locales); return(View("~/Plugins/Widgets.Gallery/Views/GalleryConfigure/Create.cshtml", model)); }
protected void UpdateLocales(Galleries gallery, ConfigurationGalleryModel model) { foreach (var localized in model.Locales) { _localizedEntityService.SaveLocalizedValue(gallery, x => x.Name, localized.Name, localized.LanguageId); _localizedEntityService.SaveLocalizedValue(gallery, x => x.Description, localized.Description, localized.LanguageId); } }
public ActionResult Edit(ConfigurationGalleryModel model) { var gallery = _galleryService.GetGalleryById(model.Id); if (gallery == null) { //No gallery found with the specified id return(RedirectToAction("List")); } if (ModelState.IsValid) { int prevPictureId = gallery.PictureId; gallery.Name = model.Name; gallery.Description = model.Description; gallery.DisplayOrder = model.DisplayOrder; gallery.PictureId = model.PictureId; gallery.VideoLink = model.VideoLink; if (!string.IsNullOrEmpty(model.GalleryType)) { switch (model.GalleryType) { case "SimpleGallery": { gallery.SimpleGallery = true; gallery.FlickrGallery = false; gallery.PicasaGallery = false; gallery.VideoGallery = false; } break; case "FlickrGallery": { gallery.FlickrGallery = true; gallery.SimpleGallery = false; gallery.PicasaGallery = false; gallery.VideoGallery = false; } break; case "PicasaGallery": { gallery.PicasaGallery = true; gallery.SimpleGallery = false; gallery.FlickrGallery = false; gallery.VideoGallery = false; } break; case "VideoGallery": { gallery.VideoGallery = true; gallery.SimpleGallery = false; gallery.FlickrGallery = false; gallery.PicasaGallery = false; } break; } } else { gallery.SimpleGallery = true; gallery.FlickrGallery = false; gallery.PicasaGallery = false; gallery.VideoGallery = false; } _galleryService.UpdateGallery(gallery); //locales UpdateLocales(gallery, model); //delete an old picture (if deleted or updated) if (prevPictureId > 0 && prevPictureId != gallery.PictureId) { var prevPicture = _pictureService.GetPictureById(prevPictureId); if (prevPicture != null) { _pictureService.DeletePicture(prevPicture); } } //update picture seo file name UpdatePictureSeoNames(gallery); //activity log SuccessNotification(_localizationService.GetResource("Plugin.Widgets.Gallery.GalleryConfigureController.Updated")); } return(View("~/Plugins/Widgets.Gallery/Views/GalleryConfigure/Edit.cshtml", model)); }
public ActionResult Create(ConfigurationGalleryModel model) { if (ModelState.IsValid) { var gallery = new Galleries { Name = model.Name, Description = model.Description, DisplayOrder = model.DisplayOrder, PictureId = model.PictureId, VideoLink = model.VideoLink, }; if (!string.IsNullOrEmpty(model.GalleryType)) { switch (model.GalleryType) { case "SimpleGallery": { gallery.SimpleGallery = true; gallery.FlickrGallery = false; gallery.PicasaGallery = false; gallery.VideoGallery = false; } break; case "FlickrGallery": { gallery.FlickrGallery = true; gallery.SimpleGallery = false; gallery.PicasaGallery = false; gallery.VideoGallery = false; } break; case "PicasaGallery": { gallery.PicasaGallery = true; gallery.SimpleGallery = false; gallery.FlickrGallery = false; gallery.VideoGallery = false; } break; case "VideoGallery": { gallery.VideoGallery = true; gallery.SimpleGallery = false; gallery.FlickrGallery = false; gallery.PicasaGallery = false; } break; } } else { gallery.SimpleGallery = true; gallery.FlickrGallery = false; gallery.PicasaGallery = false; gallery.VideoGallery = false; } _galleryService.InsertGallery(gallery); //locales UpdateLocales(gallery, model); //update picture seo file name UpdatePictureSeoNames(gallery); SuccessNotification(_localizationService.GetResource("Plugin.Widgets.Gallery.GalleryConfigureController.Added")); } return(View("~/Plugins/Widgets.Gallery/Views/GalleryConfigure/Create.cshtml", model)); }
public static Galleries ToEntity(this ConfigurationGalleryModel model, Galleries destination) { return(Mapper.Map(model, destination)); }
public static Galleries ToEntity(this ConfigurationGalleryModel model) { return(Mapper.Map <ConfigurationGalleryModel, Galleries>(model)); }