Exemple #1
0
        public virtual async Task <CustomerAttribute> InsertCustomerAttributeModel(CustomerAttributeModel model)
        {
            var customerAttribute = model.ToEntity();
            await _customerAttributeService.InsertCustomerAttribute(customerAttribute);

            return(customerAttribute);
        }
        public ActionResult Create(CustomerAttributeModel model, bool continueEditing)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageSettings))
            {
                return(AccessDeniedView());
            }

            if (ModelState.IsValid)
            {
                var customerAttribute = model.ToEntity();
                _customerAttributeService.InsertCustomerAttribute(customerAttribute);
                //locales
                UpdateAttributeLocales(customerAttribute, model);

                SuccessNotification(_localizationService.GetResource("Admin.Customers.CustomerAttributes.Added"));

                if (continueEditing)
                {
                    //selected tab
                    SaveSelectedTabName();

                    return(RedirectToAction("Edit", new { id = customerAttribute.Id }));
                }
                return(RedirectToAction("List"));
            }

            //If we got this far, something failed, redisplay form
            return(View(model));
        }
        public virtual CustomerAttribute InsertCustomerAttributeModel(CustomerAttributeModel model)
        {
            var customerAttribute = model.ToEntity();

            _customerAttributeService.InsertCustomerAttribute(customerAttribute);
            return(customerAttribute);
        }
        public virtual async Task <CustomerAttribute> InsertCustomerAttributeModel(CustomerAttributeModel model)
        {
            var customerAttribute = model.ToEntity();

            if (customerAttribute.IsReadOnly && customerAttribute.IsRequired)
            {
                customerAttribute.IsRequired = false;
            }

            await _customerAttributeService.InsertCustomerAttribute(customerAttribute);

            return(customerAttribute);
        }
Exemple #5
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 Create(CustomerAttributeModel model, bool continueEditing)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageSettings))
            {
                return(AccessDeniedView());
            }

            if (ModelState.IsValid)
            {
                var customerAttribute = model.ToEntity <CustomerAttribute>();
                _customerAttributeService.InsertCustomerAttribute(customerAttribute);

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

                //locales
                UpdateAttributeLocales(customerAttribute, model);

                SuccessNotification(_localizationService.GetResource("Admin.Customers.CustomerAttributes.Added"));

                if (!continueEditing)
                {
                    return(RedirectToAction("List"));
                }

                //selected tab
                SaveSelectedTabName();

                return(RedirectToAction("Edit", new { id = customerAttribute.Id }));
            }

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

            //if we got this far, something failed, redisplay form
            return(View(model));
        }
 /// <summary>
 /// Inserts a customer attribute
 /// </summary>
 /// <param name="customerAttribute">Customer attribute</param>
 public void InsertCustomerAttribute(CustomerAttribute customerAttribute)
 {
     _customerAttributeService.InsertCustomerAttribute(customerAttribute);
 }