Exemple #1
0
        public virtual IActionResult ValueCreatePopup(VendorAttributeValueModel model)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageSettings))
                return AccessDeniedView();

            //try to get a vendor attribute with the specified id
            var vendorAttribute = _vendorAttributeService.GetVendorAttributeById(model.VendorAttributeId);
            if (vendorAttribute == null)
                return RedirectToAction("List");

            if (ModelState.IsValid)
            {
                var value = model.ToEntity<VendorAttributeValue>();

                _vendorAttributeService.InsertVendorAttributeValue(value);

                //activity log
                _customerActivityService.InsertActivity("AddNewVendorAttributeValue",
                    string.Format(_localizationService.GetResource("ActivityLog.AddNewVendorAttributeValue"), value.Id), value);

                UpdateValueLocales(value, model);

                ViewBag.RefreshPage = true;

                return View(model);
            }

            //prepare model
            model = _vendorAttributeModelFactory.PrepareVendorAttributeValueModel(model, vendorAttribute, null, true);

            //if we got this far, something failed, redisplay form
            return View(model);
        }
Exemple #2
0
        public virtual IActionResult ValueCreatePopup(VendorAttributeValueModel model)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageSettings))
            {
                return(AccessDeniedView());
            }

            var vendorAttribute = _vendorAttributeService.GetVendorAttributeById(model.VendorAttributeId);

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

            if (ModelState.IsValid)
            {
                var value = new VendorAttributeValue
                {
                    VendorAttributeId = model.VendorAttributeId,
                    Name          = model.Name,
                    IsPreSelected = model.IsPreSelected,
                    DisplayOrder  = model.DisplayOrder
                };

                _vendorAttributeService.InsertVendorAttributeValue(value);

                //activity log
                _customerActivityService.InsertActivity("AddNewVendorAttributeValue",
                                                        string.Format(_localizationService.GetResource("ActivityLog.AddNewVendorAttributeValue"), value.Id), value);

                UpdateValueLocales(value, model);

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

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