Пример #1
0
        public virtual IActionResult EditCelebrityTag(CelebrityTagModel model, bool continueEditing)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageCelebrityTags))
            {
                return(AccessDeniedView());
            }

            //try to get a celebrity tag with the specified id
            var celebrityTag = _celebrityTagService.GetCelebrityTagById(model.Id);

            if (celebrityTag == null)
            {
                return(RedirectToAction("List"));
            }

            if (ModelState.IsValid)
            {
                celebrityTag.Name = model.Name;
                _celebrityTagService.UpdateCelebrityTag(celebrityTag);

                //locales
                UpdateLocales(celebrityTag, model);

                _notificationService.SuccessNotification(_localizationService.GetResource("Admin.Catalog.CelebrityTags.Updated"));

                return(continueEditing ? RedirectToAction("EditCelebrityTag", new { id = celebrityTag.Id }) : RedirectToAction("CelebrityTags"));
            }

            //prepare model
            model = _celebrityModelFactory.PrepareCelebrityTagModel(model, celebrityTag, true);

            //if we got this far, something failed, redisplay form
            return(View(model));
        }
Пример #2
0
        protected virtual void UpdateLocales(CelebrityTag celebrityTag, CelebrityTagModel model)
        {
            foreach (var localized in model.Locales)
            {
                _localizedEntityService.SaveLocalizedValue(celebrityTag,
                                                           x => x.Name,
                                                           localized.Name,
                                                           localized.LanguageId);

                var seName = _urlRecordService.ValidateSeName(celebrityTag, string.Empty, localized.Name, false);
                _urlRecordService.SaveSlug(celebrityTag, seName, localized.LanguageId);
            }
        }