/// <returns>A task that represents the asynchronous operation</returns>
        public virtual async Task <IActionResult> Edit(int id)
        {
            if (!await _permissionService.AuthorizeAsync(StandardPermissionProvider.ManageSettings))
            {
                return(AccessDeniedView());
            }

            //try to get a vendor attribute with the specified id
            var vendorAttribute = await _vendorAttributeService.GetVendorAttributeByIdAsync(id);

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

            //prepare model
            var model = await _vendorAttributeModelFactory.PrepareVendorAttributeModelAsync(null, vendorAttribute);

            return(View(model));
        }
Exemple #2
0
        /// <summary>
        /// Gets vendor attributes from XML
        /// </summary>
        /// <param name="attributesXml">Attributes in XML format</param>
        /// <returns>
        /// A task that represents the asynchronous operation
        /// The task result contains the list of vendor attributes
        /// </returns>
        public virtual async Task <IList <VendorAttribute> > ParseVendorAttributesAsync(string attributesXml)
        {
            var result = new List <VendorAttribute>();

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

            var ids = ParseVendorAttributeIds(attributesXml);

            foreach (var id in ids)
            {
                var attribute = await _vendorAttributeService.GetVendorAttributeByIdAsync(id);

                if (attribute != null)
                {
                    result.Add(attribute);
                }
            }

            return(result);
        }