//edit
        public virtual ActionResult PredefinedArticleAttributeValueEditPopup(int id)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageAttributes))
            {
                return(AccessDeniedView());
            }

            var ppav = _articleAttributeService.GetPredefinedArticleAttributeValueById(id);

            if (ppav == null)
            {
                throw new ArgumentException("No article attribute value found with the specified id");
            }

            var model = new PredefinedArticleAttributeValueModel
            {
                ArticleAttributeId = ppav.ArticleAttributeId,
                Name                = ppav.Name,
                PriceAdjustment     = ppav.PriceAdjustment,
                WeightAdjustment    = ppav.WeightAdjustment,
                Cost                = ppav.Cost,
                IsPreSelected       = ppav.IsPreSelected,
                DisplaySubscription = ppav.DisplaySubscription
            };

            //locales
            AddLocales(_languageService, model.Locales, (locale, languageId) =>
            {
                locale.Name = ppav.GetLocalized(x => x.Name, languageId, false, false);
            });
            return(View(model));
        }
 protected virtual void UpdateLocales(PredefinedArticleAttributeValue ppav, PredefinedArticleAttributeValueModel model)
 {
     foreach (var localized in model.Locales)
     {
         _localizedEntityService.SaveLocalizedValue(ppav,
                                                    x => x.Name,
                                                    localized.Name,
                                                    localized.LanguageId);
     }
 }
        //create
        public virtual ActionResult PredefinedArticleAttributeValueCreatePopup(int articleAttributeId)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageAttributes))
            {
                return(AccessDeniedView());
            }

            var articleAttribute = _articleAttributeService.GetArticleAttributeById(articleAttributeId);

            if (articleAttribute == null)
            {
                throw new ArgumentException("No article attribute found with the specified id");
            }

            var model = new PredefinedArticleAttributeValueModel();

            model.ArticleAttributeId = articleAttributeId;

            //locales
            AddLocales(_languageService, model.Locales);

            return(View(model));
        }
        public virtual ActionResult PredefinedArticleAttributeValueEditPopup(string btnId, string formId, PredefinedArticleAttributeValueModel model)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageAttributes))
            {
                return(AccessDeniedView());
            }

            var ppav = _articleAttributeService.GetPredefinedArticleAttributeValueById(model.Id);

            if (ppav == null)
            {
                throw new ArgumentException("No article attribute value found with the specified id");
            }

            if (ModelState.IsValid)
            {
                ppav.Name                = model.Name;
                ppav.PriceAdjustment     = model.PriceAdjustment;
                ppav.WeightAdjustment    = model.WeightAdjustment;
                ppav.Cost                = model.Cost;
                ppav.IsPreSelected       = model.IsPreSelected;
                ppav.DisplaySubscription = model.DisplaySubscription;
                _articleAttributeService.UpdatePredefinedArticleAttributeValue(ppav);

                UpdateLocales(ppav, model);

                ViewBag.RefreshPage = true;
                ViewBag.btnId       = btnId;
                ViewBag.formId      = formId;
                return(View(model));
            }

            //If we got this far, something failed, redisplay form
            return(View(model));
        }