예제 #1
0
        public virtual async Task <CustomerAttributeValue> InsertCustomerAttributeValueModel(CustomerAttributeValueModel model)
        {
            var cav = model.ToEntity();
            await _customerAttributeService.InsertCustomerAttributeValue(cav);

            return(cav);
        }
예제 #2
0
        public virtual async Task <CustomerAttributeValue> UpdateCustomerAttributeValueModel(CustomerAttributeValueModel model, CustomerAttributeValue customerAttributeValue)
        {
            customerAttributeValue = model.ToEntity(customerAttributeValue);
            await _customerAttributeService.UpdateCustomerAttributeValue(customerAttributeValue);

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

            _customerAttributeService.InsertCustomerAttributeValue(cav);
            return(cav);
        }
        public virtual async Task<IActionResult> ValueCreatePopup(CustomerAttributeValueModel model)
        {
            if (!await _permissionService.AuthorizeAsync(StandardPermissionProvider.ManageSettings))
                return AccessDeniedView();

            //try to get a customer attribute with the specified id
            var customerAttribute = await _customerAttributeService.GetCustomerAttributeByIdAsync(model.CustomerAttributeId);
            if (customerAttribute == null)
                return RedirectToAction("List");

            if (ModelState.IsValid)
            {
                var cav = model.ToEntity<CustomerAttributeValue>();
                await _customerAttributeService.InsertCustomerAttributeValueAsync(cav);

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

                await UpdateValueLocalesAsync(cav, model);

                ViewBag.RefreshPage = true;

                return View(model);
            }

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

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

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

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

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

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

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

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

                UpdateValueLocales(customerAttributeValue, model);

                ViewBag.RefreshPage = true;

                return(View(model));
            }

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

            //if we got this far, something failed, redisplay form
            return(View(model));
        }
 public virtual CustomerAttributeValue UpdateCustomerAttributeValueModel(CustomerAttributeValueModel model, CustomerAttributeValue customerAttributeValue)
 {
     customerAttributeValue = model.ToEntity(customerAttributeValue);
     _customerAttributeService.UpdateCustomerAttributeValue(customerAttributeValue);
     return(customerAttributeValue);
 }