Exemple #1
0
        public async Task <IActionResult> Edit(CustomerTagModel model, bool continueEditing)
        {
            var customertag = await _customerTagService.GetCustomerTagById(model.Id);

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

            try
            {
                if (ModelState.IsValid)
                {
                    customertag = await _customerTagViewModelService.UpdateCustomerTagModel(customertag, model);

                    SuccessNotification(_localizationService.GetResource("Admin.Customers.CustomerTags.Updated"));
                    return(continueEditing ? RedirectToAction("Edit", new { id = customertag.Id }) : RedirectToAction("List"));
                }

                //If we got this far, something failed, redisplay form
                return(View(model));
            }
            catch (Exception exc)
            {
                ErrorNotification(exc);
                return(RedirectToAction("Edit", new { id = customertag.Id }));
            }
        }
        public IActionResult Create()
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageCustomers))
                return AccessDeniedView();

            var model = new CustomerTagModel();
            return View(model);
        }
        public virtual CustomerTag UpdateCustomerTagModel(CustomerTag customerTag, CustomerTagModel model)
        {
            customerTag      = model.ToEntity(customerTag);
            customerTag.Name = customerTag.Name.ToLower();

            _customerTagService.UpdateCustomerTag(customerTag);

            //activity log
            _customerActivityService.InsertActivity("EditCustomerTage", customerTag.Id, _localizationService.GetResource("ActivityLog.EditCustomerTag"), customerTag.Name);
            return(customerTag);
        }
        public virtual CustomerTag InsertCustomerTagModel(CustomerTagModel model)
        {
            var customertag = model.ToEntity();

            customertag.Name = customertag.Name.ToLower();
            _customerTagService.InsertCustomerTag(customertag);

            //activity log
            _customerActivityService.InsertActivity("AddNewCustomerTag", customertag.Id, _localizationService.GetResource("ActivityLog.AddNewCustomerTag"), customertag.Name);
            return(customertag);
        }
Exemple #5
0
        public virtual async Task <CustomerTag> InsertCustomerTagModel(CustomerTagModel model)
        {
            var customertag = model.ToEntity();

            customertag.Name = customertag.Name.ToLower();
            await _customerTagService.InsertCustomerTag(customertag);

            //activity log
            await _customerActivityService.InsertActivity("AddNewCustomerTag", customertag.Id, _translationService.GetResource("ActivityLog.AddNewCustomerTag"), customertag.Name);

            return(customertag);
        }
Exemple #6
0
        public IActionResult Create(CustomerTagModel model, bool continueEditing)
        {
            if (ModelState.IsValid)
            {
                var customertag = _customerTagViewModelService.InsertCustomerTagModel(model);
                SuccessNotification(_localizationService.GetResource("Admin.Customers.CustomerTags.Added"));
                return(continueEditing ? RedirectToAction("Edit", new { id = customertag.Id }) : RedirectToAction("List"));
            }

            //If we got this far, something failed, redisplay form
            return(View(model));
        }
        public IActionResult Create(CustomerTagModel model, bool continueEditing)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageCustomers))
                return AccessDeniedView();

            if (ModelState.IsValid)
            {
                var customertag = model.ToEntity();
                customertag.Name = customertag.Name.ToLower();
                _customerTagService.InsertCustomerTag(customertag);

                //activity log
                _customerActivityService.InsertActivity("AddNewCustomerTag", customertag.Id, _localizationService.GetResource("ActivityLog.AddNewCustomerTag"), customertag.Name);

                SuccessNotification(_localizationService.GetResource("Admin.Customers.CustomerTags.Added"));
                return continueEditing ? RedirectToAction("Edit", new { id = customertag.Id }) : RedirectToAction("List");
            }

            //If we got this far, something failed, redisplay form
            return View(model);
        }
Exemple #8
0
        public IActionResult Edit(CustomerTagModel model, bool continueEditing)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageCustomers))
            {
                return(AccessDeniedView());
            }

            var customertag = _customerTagService.GetCustomerTagById(model.Id);

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

            try
            {
                if (ModelState.IsValid)
                {
                    customertag      = model.ToEntity(customertag);
                    customertag.Name = customertag.Name.ToLower();

                    _customerTagService.UpdateCustomerTag(customertag);

                    //activity log
                    _customerActivityService.InsertActivity("EditCustomerTage", customertag.Id, _localizationService.GetResource("ActivityLog.EditCustomerTag"), customertag.Name);

                    SuccessNotification(_localizationService.GetResource("Admin.Customers.CustomerTags.Updated"));
                    return(continueEditing ? RedirectToAction("Edit", new { id = customertag.Id }) : RedirectToAction("List"));
                }

                //If we got this far, something failed, redisplay form
                return(View(model));
            }
            catch (Exception exc)
            {
                ErrorNotification(exc);
                return(RedirectToAction("Edit", new { id = customertag.Id }));
            }
        }
Exemple #9
0
        public virtual CustomerTagModel PrepareCustomerTagModel()
        {
            var model = new CustomerTagModel();

            return(model);
        }
Exemple #10
0
        public virtual async Task <CustomerTag> UpdateCustomerTagModel(CustomerTag customerTag, CustomerTagModel model)
        {
            customerTag      = model.ToEntity(customerTag);
            customerTag.Name = customerTag.Name.ToLower();

            await _customerTagService.UpdateCustomerTag(customerTag);

            //activity log
            await _customerActivityService.InsertActivity("EditCustomerTage", customerTag.Id, _translationService.GetResource("ActivityLog.EditCustomerTag"), customerTag.Name);

            return(customerTag);
        }
 public static CustomerTag ToEntity(this CustomerTagModel model, CustomerTag destination)
 {
     return(model.MapTo(destination));
 }
 public static CustomerTag ToEntity(this CustomerTagModel model)
 {
     return(model.MapTo <CustomerTagModel, CustomerTag>());
 }