public async Task <IActionResult> Edit(string id)
        {
            var slide = await _sliderService.GetById(id);

            if (slide == null)
            {
                return(RedirectToAction("Configure"));
            }

            var model = slide.ToModel();

            //locales
            await AddLocales(_languageService, model.Locales, (locale, languageId) =>
            {
                locale.Name        = slide.GetLocalized(x => x.Name, languageId, false, false);
                locale.Description = slide.GetLocalized(x => x.Description, languageId, false, false);
            });

            //Stores
            await model.PrepareStoresMappingModel(slide, false, _storeService);

            //Categories
            await PrepareAllCategoriesModel(model);

            //Manufacturers
            await PrepareAllManufacturersModel(model);

            return(View("~/Plugins/Widgets.Slider/Views/Edit.cshtml", model));
        }
Example #2
0
        public IActionResult Edit(string id)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManagePlugins))
            {
                return(AccessDeniedView());
            }

            var slide = _sliderService.GetById(id);

            if (slide == null)
            {
                return(RedirectToAction("Configure"));
            }

            var model = slide.ToModel();

            //locales
            AddLocales(_languageService, model.Locales, (locale, languageId) =>
            {
                locale.Name        = slide.GetLocalized(x => x.Name, languageId, false, false);
                locale.Description = slide.GetLocalized(x => x.Description, languageId, false, false);
            });
            //Stores
            PrepareStoresMappingModel(model, slide, false);
            //Categories
            PrepareAllCategoriesModel(model);
            //Manufacturers
            PrepareAllManufacturersModel(model);

            return(View("~/Plugins/Widgets.Slider/Views/Edit.cshtml", model));
        }
        public IActionResult UpdateSlider(int id)
        {
            if (id == 0)
            {
                ViewData["GeneralError"] = Messages.GeneralError;
                return(RedirectToAction("ListSlider", "ManagementPanel"));
            }

            var data = _sliderService.GetById(id);



            if (data.Data != null)
            {
                UpdateSliderViewModel model = new UpdateSliderViewModel
                {
                    Link        = data.Data.Link,
                    LinkName    = data.Data.LinkName,
                    Description = data.Data.Description,
                    Id          = data.Data.Id,
                    Name        = data.Data.Name
                };
                return(View(model));
            }

            ViewData["GeneralError"] = Messages.GeneralError;

            return(RedirectToAction("ListSlider", "ManagementPanel"));
        }
Example #4
0
 public ActionResult Update(int?id)
 {
     if (id.HasValue)
     {
         var model = _Service.GetById(id.Value);
         ViewBag.Slider = "active";
         return(View(model));
     }
     return(RedirectToAction("Add"));
 }
Example #5
0
        public IActionResult Edit(int id)
        {
            var slider = _sliderService.GetById(id);

            ViewData["Posts"] = _postService.GetDefaultQuery().Select(p => new SelectListItem()
            {
                Text = p.ShortTitle, Value = p.Id.ToString(), Selected = p.Id == slider.PostId
            });
            return(PartialView(slider));
        }
Example #6
0
        // GET: Admin/EditSlider
        public ActionResult Edit(int id)
        {
            var entity = _sliderService.GetById(id);

            var viewModel = Mapper.Map <Slider, SliderViewModel>(entity);

            AddLocales(viewModel.Locales, (locale, languageId) =>
            {
                locale.Title       = entity.GetLocalized(x => x.Title, languageId);
                locale.Description = entity.GetLocalized(x => x.Description, languageId);
            });

            return(View(viewModel));
        }
        public async Task <IActionResult> Edit(string id)
        {
            var slide = await _sliderService.GetById(id);

            if (slide == null)
            {
                return(RedirectToAction("Configure"));
            }

            var model = slide.ToModel();

            //locales
            await AddLocales(_languageService, model.Locales, (locale, languageId) =>
            {
                locale.Name        = slide.GetTranslation(x => x.Name, languageId, false);
                locale.Description = slide.GetTranslation(x => x.Description, languageId, false);
            });

            return(View("~/Plugins/Widgets.Slider/Views/Edit.cshtml", model));
        }
 public ActionResult Details(int id)
 {
     try
     {
         var model  = _sliderService.GetById(id);
         var result = _mapper.Map <SliderViewModel>(model);
         return(View(result));
     }
     catch (Exception ex)
     {
         _logger.Error(ex);
         if (ex.InnerException != null && ex.InnerException.Source.Equals(GeneralMessages.ExceptionSource))
         {
             ModelState.AddModelError(string.Empty, ex.Message);
         }
         else
         {
             ModelState.AddModelError(string.Empty, GeneralMessages.UnexpectedError);
         }
         return(View());
     }
 }
Example #9
0
        public IActionResult EditSlider(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            var entity = _sliderService.GetById((int)id);

            if (entity == null)
            {
                return(NotFound());
            }

            var model = new SliderModel()
            {
                Id          = entity.Id,
                Title       = entity.Title,
                Description = entity.Description,
                ImageUrl    = entity.ImageUrl
            };

            return(View(model));
        }