コード例 #1
0
        public IActionResult Create(AddressAttributeModel model, bool continueEditing)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageSettings))
            {
                return(AccessDeniedView());
            }

            if (ModelState.IsValid)
            {
                var addressAttribute = model.ToEntity();
                addressAttribute.Locales.Clear();
                foreach (var local in model.Locales)
                {
                    if (!(String.IsNullOrEmpty(local.Name)))
                    {
                        addressAttribute.Locales.Add(new Core.Domain.Localization.LocalizedProperty()
                        {
                            LanguageId  = local.LanguageId,
                            LocaleKey   = "Name",
                            LocaleValue = local.Name
                        });
                    }
                }
                _addressAttributeService.InsertAddressAttribute(addressAttribute);
                //locales
                //UpdateAttributeLocales(addressAttribute, model);


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

            //If we got this far, something failed, redisplay form
            return(View(model));
        }
コード例 #2
0
        public virtual IActionResult Create(AddressAttributeModel model, bool continueEditing)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageSettings))
            {
                return(AccessDeniedView());
            }

            if (ModelState.IsValid)
            {
                var addressAttribute = model.ToEntity();
                _addressAttributeService.InsertAddressAttribute(addressAttribute);

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

                //locales
                UpdateAttributeLocales(addressAttribute, model);

                SuccessNotification(_localizationService.GetResource("Admin.Address.AddressAttributes.Added"));

                if (continueEditing)
                {
                    //selected tab
                    SaveSelectedTabName();

                    return(RedirectToAction("Edit", new { id = addressAttribute.Id }));
                }
                return(RedirectToAction("List"));
            }

            //If we got this far, something failed, redisplay form
            return(View(model));
        }
コード例 #3
0
        public ActionResult Create(AddressAttributeModel model, bool continueEditing)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageSettings))
                return AccessDeniedView();

            if (ModelState.IsValid)
            {
                var addressAttribute = model.ToEntity();
                addressAttribute.Locales.Clear();
                foreach(var local in model.Locales)
                {
                    if(!(String.IsNullOrEmpty(local.Name)))
                        addressAttribute.Locales.Add(new Core.Domain.Localization.LocalizedProperty()
                        {
                            LanguageId = local.LanguageId,
                            LocaleKey = "Name",
                            LocaleValue = local.Name
                        });
                }
                _addressAttributeService.InsertAddressAttribute(addressAttribute);
                //locales
                //UpdateAttributeLocales(addressAttribute, model);

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

            //If we got this far, something failed, redisplay form
            return View(model);
        }
コード例 #4
0
        public virtual async Task <AddressAttribute> UpdateAddressAttributeModel(AddressAttributeModel model, AddressAttribute addressAttribute)
        {
            addressAttribute = model.ToEntity(addressAttribute);
            await _addressAttributeService.UpdateAddressAttribute(addressAttribute);

            return(addressAttribute);
        }
コード例 #5
0
        public virtual async Task <AddressAttribute> InsertAddressAttributeModel(AddressAttributeModel model)
        {
            var addressAttribute = model.ToEntity();
            await _addressAttributeService.InsertAddressAttribute(addressAttribute);

            return(addressAttribute);
        }
        public virtual AddressAttribute InsertAddressAttributeModel(AddressAttributeModel model)
        {
            var addressAttribute = model.ToEntity();

            _addressAttributeService.InsertAddressAttribute(addressAttribute);

            return(addressAttribute);
        }
コード例 #7
0
        public ActionResult Edit(AddressAttributeModel model, bool continueEditing)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageSettings))
            {
                return(AccessDeniedView());
            }

            var addressAttribute = _addressAttributeService.GetAddressAttributeById(model.Id);

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

            if (ModelState.IsValid)
            {
                addressAttribute = model.ToEntity(addressAttribute);
                addressAttribute.Locales.Clear();
                foreach (var local in model.Locales)
                {
                    if (!(String.IsNullOrEmpty(local.Name)))
                    {
                        addressAttribute.Locales.Add(new Core.Domain.Localization.LocalizedProperty()
                        {
                            LanguageId  = local.LanguageId,
                            LocaleKey   = "Name",
                            LocaleValue = local.Name
                        });
                    }
                }
                _addressAttributeService.UpdateAddressAttribute(addressAttribute);
                //locales
                //UpdateAttributeLocales(addressAttribute, model);

                SuccessNotification(_localizationService.GetResource("Admin.Address.AddressAttributes.Updated"));
                if (continueEditing)
                {
                    //selected tab
                    SaveSelectedTabIndex();

                    return(RedirectToAction("Edit", new { id = addressAttribute.Id }));
                }
                return(RedirectToAction("List"));
            }

            //If we got this far, something failed, redisplay form
            return(View(model));
        }
コード例 #8
0
        public virtual IActionResult Edit(AddressAttributeModel model, bool continueEditing)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageSettings))
            {
                return(AccessDeniedView());
            }

            //try to get an address attribute with the specified id
            var addressAttribute = _addressAttributeService.GetAddressAttributeById(model.Id);

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

            if (ModelState.IsValid)
            {
                addressAttribute = model.ToEntity(addressAttribute);
                _addressAttributeService.UpdateAddressAttribute(addressAttribute);

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

                //locales
                UpdateAttributeLocales(addressAttribute, model);

                SuccessNotification(_localizationService.GetResource("Admin.Address.AddressAttributes.Updated"));

                if (!continueEditing)
                {
                    return(RedirectToAction("List"));
                }

                //selected tab
                SaveSelectedTabName();

                return(RedirectToAction("Edit", new { id = addressAttribute.Id }));
            }

            //prepare model
            model = _addressAttributeModelFactory.PrepareAddressAttributeModel(model, addressAttribute, true);

            //if we got this far, something failed, redisplay form
            return(View(model));
        }
コード例 #9
0
        public virtual async Task <IActionResult> Edit(AddressAttributeModel model, bool continueEditing)
        {
            if (!await _permissionService.AuthorizeAsync(StandardPermissionProvider.ManageSettings))
            {
                return(AccessDeniedView());
            }

            //try to get an address attribute with the specified id
            var addressAttribute = await _addressAttributeService.GetAddressAttributeByIdAsync(model.Id);

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

            if (ModelState.IsValid)
            {
                addressAttribute = model.ToEntity(addressAttribute);
                await _addressAttributeService.UpdateAddressAttributeAsync(addressAttribute);

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

                //locales
                await UpdateAttributeLocalesAsync(addressAttribute, model);

                _notificationService.SuccessNotification(await _localizationService.GetResourceAsync("Admin.Address.AddressAttributes.Updated"));

                if (!continueEditing)
                {
                    return(RedirectToAction("List"));
                }

                return(RedirectToAction("Edit", new { id = addressAttribute.Id }));
            }

            //prepare model
            model = await _addressAttributeModelFactory.PrepareAddressAttributeModelAsync(model, addressAttribute, true);

            //if we got this far, something failed, redisplay form
            return(View(model));
        }
コード例 #10
0
        public ActionResult Create(AddressAttributeModel model, bool continueEditing)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageSettings))
                return AccessDeniedView();

            if (ModelState.IsValid)
            {
                var addressAttribute = model.ToEntity();
                _addressAttributeService.InsertAddressAttribute(addressAttribute);
                //locales
                UpdateAttributeLocales(addressAttribute, model);

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

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

            if (ModelState.IsValid)
            {
                var addressAttribute = model.ToEntity();
                _addressAttributeService.InsertAddressAttribute(addressAttribute);
                //locales
                UpdateAttributeLocales(addressAttribute, model);

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

            //If we got this far, something failed, redisplay form
            return(View(model));
        }
コード例 #12
0
        public ActionResult Edit(AddressAttributeModel model, bool continueEditing)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageSettings))
            {
                return(AccessDeniedView());
            }

            var addressAttribute = _addressAttributeService.GetAddressAttributeById(model.Id);

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

            if (ModelState.IsValid)
            {
                addressAttribute = model.ToEntity(addressAttribute);
                _addressAttributeService.UpdateAddressAttribute(addressAttribute);
                //locales
                UpdateAttributeLocales(addressAttribute, model);

                SuccessNotification(_localizationService.GetResource("Admin.Address.AddressAttributes.Updated"));
                if (continueEditing)
                {
                    //selected tab
                    SaveSelectedTabName();

                    return(RedirectToAction("Edit", new { id = addressAttribute.Id }));
                }
                return(RedirectToAction("List"));
            }

            //If we got this far, something failed, redisplay form
            return(View(model));
        }
 public virtual AddressAttribute UpdateAddressAttributeModel(AddressAttributeModel model, AddressAttribute addressAttribute)
 {
     addressAttribute = model.ToEntity(addressAttribute);
     _addressAttributeService.UpdateAddressAttribute(addressAttribute);
     return(addressAttribute);
 }
コード例 #14
0
        public ActionResult Edit(AddressAttributeModel model, bool continueEditing)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageSettings))
                return AccessDeniedView();

            var addressAttribute = _addressAttributeService.GetAddressAttributeById(model.Id);
            if (addressAttribute == null)
                //No address attribute found with the specified id
                return RedirectToAction("List");

            if (ModelState.IsValid)
            {
                addressAttribute = model.ToEntity(addressAttribute);
                _addressAttributeService.UpdateAddressAttribute(addressAttribute);
                //locales
                UpdateAttributeLocales(addressAttribute, model);

                SuccessNotification(_localizationService.GetResource("Admin.Address.AddressAttributes.Updated"));
                if (continueEditing)
                {
                    //selected tab
                    SaveSelectedTabName();

                    return RedirectToAction("Edit", new {id = addressAttribute.Id});
                }
                return RedirectToAction("List");
            }

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