public virtual CustomerAttributeValue InsertCustomerAttributeValueModel(CustomerAttributeValueModel model)
        {
            var cav = model.ToEntity();

            _customerAttributeService.InsertCustomerAttributeValue(cav);
            return(cav);
        }
Esempio n. 2
0
        public virtual async Task <CustomerAttributeValue> InsertCustomerAttributeValueModel(CustomerAttributeValueModel model)
        {
            var cav = model.ToEntity();
            await _customerAttributeService.InsertCustomerAttributeValue(cav);

            return(cav);
        }
        public IActionResult ValueCreatePopup(CustomerAttributeValueModel model)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageSettings))
            {
                return(AccessDeniedView());
            }

            var customerAttribute = _customerAttributeService.GetCustomerAttributeById(model.CustomerAttributeId);

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

            if (ModelState.IsValid)
            {
                var cav = new CustomerAttributeValue
                {
                    CustomerAttributeId = model.CustomerAttributeId,
                    Name          = model.Name,
                    IsPreSelected = model.IsPreSelected,
                    DisplayOrder  = model.DisplayOrder
                };
                cav.Locales = UpdateValueLocales(cav, model);
                _customerAttributeService.InsertCustomerAttributeValue(cav);


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

            //If we got this far, something failed, redisplay form
            return(View(model));
        }
Esempio n. 4
0
        public override void Install()
        {
            // create customer attributes
            var requiredPasswordChangeCustomerAttribute = GetRequiredPasswordChangeCustomerAttribute();

            if (requiredPasswordChangeCustomerAttribute == null)
            {
                var reqPassChangeCustAttr = new CustomerAttribute()
                {
                    Name = RequirePasswordChangePluginCustomerAttributeNames.RequiredPasswordChange,
                    AttributeControlType   = AttributeControlType.RadioList,
                    AttributeControlTypeId = (int)AttributeControlType.RadioList,
                    IsRequired             = false,
                };

                _customerAttributeService.InsertCustomerAttribute(reqPassChangeCustAttr);

                var reqPassChangeCustAttrValueYes = new CustomerAttributeValue()
                {
                    CustomerAttribute   = reqPassChangeCustAttr,
                    CustomerAttributeId = reqPassChangeCustAttr.Id,
                    IsPreSelected       = true,
                    DisplayOrder        = int.MinValue,
                    Name = RequirePasswordChangePluginCustomerAttributeValueNames.RequiredPasswordChangeYes
                };

                var reqPassChangeCustAttrValueNo = new CustomerAttributeValue()
                {
                    CustomerAttribute   = reqPassChangeCustAttr,
                    CustomerAttributeId = reqPassChangeCustAttr.Id,
                    IsPreSelected       = false,
                    DisplayOrder        = int.MaxValue,
                    Name = RequirePasswordChangePluginCustomerAttributeValueNames.RequiredPasswordChangeNo
                };

                _customerAttributeService.InsertCustomerAttributeValue(reqPassChangeCustAttrValueYes);
                _customerAttributeService.InsertCustomerAttributeValue(reqPassChangeCustAttrValueNo);
            }

            //locales
            foreach (var localeResourceKvp in GetLocaleResourceStrings())
            {
                this.AddOrUpdatePluginLocaleResource(localeResourceKvp.Key, localeResourceKvp.Value);
            }

            base.Install();
        }
        public virtual IActionResult ValueCreatePopup(CustomerAttributeValueModel model)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageSettings))
            {
                return(AccessDeniedView());
            }

            //try to get a customer attribute with the specified id
            var customerAttribute = _customerAttributeService.GetCustomerAttributeById(model.CustomerAttributeId);

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

            if (ModelState.IsValid)
            {
                var cav = new CustomerAttributeValue
                {
                    CustomerAttributeId = model.CustomerAttributeId,
                    Name          = model.Name,
                    IsPreSelected = model.IsPreSelected,
                    DisplayOrder  = model.DisplayOrder
                };

                _customerAttributeService.InsertCustomerAttributeValue(cav);

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

                UpdateValueLocales(cav, model);

                ViewBag.RefreshPage = true;

                return(View(model));
            }

            //prepare model
            model = _customerAttributeModelFactory.PrepareCustomerAttributeValueModel(model, customerAttribute, null, true);

            //if we got this far, something failed, redisplay form
            return(View(model));
        }
        public virtual ActionResult ValueCreatePopup(string btnId, string formId, CustomerAttributeValueModel model)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageSettings))
            {
                return(AccessDeniedView());
            }

            var customerAttribute = _customerAttributeService.GetCustomerAttributeById(model.CustomerAttributeId);

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

            if (ModelState.IsValid)
            {
                var cav = new CustomerAttributeValue
                {
                    CustomerAttributeId = model.CustomerAttributeId,
                    Name          = model.Name,
                    IsPreSelected = model.IsPreSelected,
                    DisplayOrder  = model.DisplayOrder
                };

                _customerAttributeService.InsertCustomerAttributeValue(cav);

                //activity log
                _customerActivityService.InsertActivity("AddNewCustomerAttributeValue", _localizationService.GetResource("ActivityLog.AddNewCustomerAttributeValue"), cav.Id);

                UpdateValueLocales(cav, 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));
        }
Esempio n. 7
0
 /// <summary>
 /// Inserts a customer attribute value
 /// </summary>
 /// <param name="customerAttributeValue">Customer attribute value</param>
 public void InsertCustomerAttributeValue(CustomerAttributeValue customerAttributeValue)
 {
     _customerAttributeService.InsertCustomerAttributeValue(customerAttributeValue);
 }