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

            //try to get a customer attribute value with the specified id
            var customerAttributeValue = await _customerAttributeService.GetCustomerAttributeValueByIdAsync(model.Id);

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

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

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

            if (ModelState.IsValid)
            {
                customerAttributeValue = model.ToEntity(customerAttributeValue);
                await _customerAttributeService.UpdateCustomerAttributeValueAsync(customerAttributeValue);

                //activity log
                await _customerActivityService.InsertActivityAsync("EditCustomerAttributeValue",
                                                                   string.Format(await _localizationService.GetResourceAsync("ActivityLog.EditCustomerAttributeValue"), customerAttributeValue.Id),
                                                                   customerAttributeValue);

                await UpdateValueLocalesAsync(customerAttributeValue, model);

                ViewBag.RefreshPage = true;

                return(View(model));
            }

            //prepare model
            model = await _customerAttributeModelFactory.PrepareCustomerAttributeValueModelAsync(model, customerAttribute, customerAttributeValue, true);

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