예제 #1
0
        public IList <CustomerAttribute> ParseCustomerAttributes(string attributesXml)
        {
            var result = new List <CustomerAttribute>();
            var ids    = ParseCustomerAttributeIds(attributesXml);

            foreach (var id in ids)
            {
                var attribute = _customerAttributeService.GetCustomerAttributeById(id);
                if (attribute != null)
                {
                    result.Add(attribute);
                }
            }
            return(result);
        }
        //edit
        public virtual ActionResult Edit(int id)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageSettings))
            {
                return(AccessDeniedView());
            }

            var customerAttribute = _customerAttributeService.GetCustomerAttributeById(id);

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

            var model = customerAttribute.ToModel();

            //locales
            AddLocales(_languageService, model.Locales, (locale, languageId) =>
            {
                locale.Name = customerAttribute.GetLocalized(x => x.Name, languageId, false, false);
            });
            return(View(model));
        }
        /// <summary>
        /// Gets selected customer attributes
        /// </summary>
        /// <param name="attributes">Attributes</param>
        /// <returns>Selected customer attributes</returns>
        public virtual IList <CustomerAttribute> ParseCustomerAttributes(string attributes)
        {
            var caCollection = new List <CustomerAttribute>();
            var ids          = ParseCustomerAttributeIds(attributes);

            foreach (int id in ids)
            {
                var ca = _customerAttributeService.GetCustomerAttributeById(id);
                if (ca != null)
                {
                    caCollection.Add(ca);
                }
            }
            return(caCollection);
        }
        public virtual IActionResult Edit(int id)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageSettings))
            {
                return(AccessDeniedView());
            }

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

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

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

            return(View(model));
        }
        private async Task<string> CustomerAttribute(string registerField)
        {
            string _field = registerField;
            var _rf = registerField.Split(':');
            if (_rf.Count() > 1)
            {
                var ca = await _customerAttributeService.GetCustomerAttributeById(_rf.FirstOrDefault());
                if (ca != null)
                {
                    _field = ca.Name;
                    if (ca.CustomerAttributeValues.FirstOrDefault(x => x.Id == _rf.LastOrDefault()) != null)
                    {
                        _field = ca.Name + "->" + ca.CustomerAttributeValues.FirstOrDefault(x => x.Id == _rf.LastOrDefault()).Name;
                    }
                }

            }

            return _field;
        }
예제 #6
0
        /// <summary>
        /// Gets selected customer attributes
        /// </summary>
        /// <param name="customAttributes">Attributes</param>
        /// <returns>Selected customer attributes</returns>
        public virtual async Task <IList <CustomerAttribute> > ParseCustomerAttributes(IList <CustomAttribute> customAttributes)
        {
            var result = new List <CustomerAttribute>();

            if (customAttributes == null || !customAttributes.Any())
            {
                return(result);
            }

            foreach (var customAttribute in customAttributes.GroupBy(x => x.Key))
            {
                var attribute = await _customerAttributeService.GetCustomerAttributeById(customAttribute.Key);

                if (attribute != null)
                {
                    result.Add(attribute);
                }
            }
            return(result);
        }
예제 #7
0
        /// <summary>
        /// Gets selected customer attributes
        /// </summary>
        /// <param name="attributesXml">Attributes in XML format</param>
        /// <returns>Selected customer attributes</returns>
        public virtual IList <CustomerAttribute> ParseCustomerAttributes(string attributesXml)
        {
            var result = new List <CustomerAttribute>();

            if (String.IsNullOrEmpty(attributesXml))
            {
                return(result);
            }

            var ids = ParseCustomerAttributeIds(attributesXml);

            foreach (string id in ids)
            {
                var attribute = _customerAttributeService.GetCustomerAttributeById(id);
                if (attribute != null)
                {
                    result.Add(attribute);
                }
            }
            return(result);
        }
        //edit
        public IActionResult Edit(string id)
        {
            var customerAttribute = _customerAttributeService.GetCustomerAttributeById(id);

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

            var model = _customerAttributeViewModelService.PrepareCustomerAttributeModel(customerAttribute);

            //locales
            AddLocales(_languageService, model.Locales, (locale, languageId) =>
            {
                locale.Name = customerAttribute.GetLocalized(x => x.Name, languageId, false, false);
            });
            return(View(model));
        }
예제 #9
0
 /// <summary>
 /// Gets a customer attribute
 /// </summary>
 /// <param name="customerAttributeId">Customer attribute identifier</param>
 /// <returns>Customer attribute</returns>
 public CustomerAttribute GetCustomerAttributeById(int customerAttributeId)
 {
     return(_customerAttributeService.GetCustomerAttributeById(customerAttributeId));
 }