Пример #1
0
        public ActionResult Edit(ProductAttributeModel model, bool continueEditing)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageCatalog))
            {
                return(AccessDeniedView());
            }

            var productAttribute = _productAttributeService.GetProductAttributeById(model.Id);

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

            if (ModelState.IsValid)
            {
                productAttribute = model.ToEntity(productAttribute);
                _productAttributeService.UpdateProductAttribute(productAttribute);

                UpdateLocales(productAttribute, model);

                //activity log
                _customerActivityService.InsertActivity("EditProductAttribute", _localizationService.GetResource("ActivityLog.EditProductAttribute"), productAttribute.Name);

                SuccessNotification(_localizationService.GetResource("Admin.Catalog.Attributes.ProductAttributes.Updated"));
                return(continueEditing ? RedirectToAction("Edit", productAttribute.Id) : RedirectToAction("List"));
            }

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

            //decode description
            model.Description = HttpUtility.HtmlDecode(model.Description);
            foreach (var localized in model.Locales)
            {
                localized.Description = HttpUtility.HtmlDecode(localized.Description);
            }

            if (ModelState.IsValid)
            {
                var productAttribute = model.ToEntity();
                _productAttributeService.InsertProductAttribute(productAttribute);
                UpdateLocales(productAttribute, model);

                //activity log
                _customerActivityService.InsertActivity("AddNewProductAttribute", _localizationService.GetResource("ActivityLog.AddNewProductAttribute"), productAttribute.Name);

                SuccessNotification(_localizationService.GetResource("Admin.Catalog.Attributes.ProductAttributes.Added"));
                return(continueEditing ? RedirectToAction("Edit", new { id = productAttribute.Id }) : RedirectToAction("List"));
            }

            //If we got this far, something failed, redisplay form
            return(View(model));
        }
Пример #3
0
        public IActionResult Edit(ProductAttributeModel model, bool continueEditing)
        {
            var productAttribute = _productAttributeService.GetProductAttributeById(model.Id);

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

            if (ModelState.IsValid)
            {
                productAttribute = model.ToEntity(productAttribute);
                _productAttributeService.UpdateProductAttribute(productAttribute);

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

                SuccessNotification(_localizationService.GetResource("Admin.Catalog.Attributes.ProductAttributes.Updated"));
                if (continueEditing)
                {
                    //selected tab
                    SaveSelectedTabIndex();

                    return(RedirectToAction("Edit", new { id = productAttribute.Id }));
                }
                return(RedirectToAction("List"));
            }
            //If we got this far, something failed, redisplay form
            return(View(model));
        }
        public ActionResult Create(ProductAttributeModel model, bool continueEditing)
        {
            if (ModelState.IsValid)
            {
                var productAttribute = model.ToEntity();

                try
                {
                    _productAttributeService.InsertProductAttribute(productAttribute);
                }
                catch (Exception ex)
                {
                    ModelState.AddModelError("", ex.Message);
                    return(View(model));
                }

                try
                {
                    UpdateLocales(productAttribute, model);
                }
                catch { }

                _customerActivityService.InsertActivity("AddNewProductAttribute", T("ActivityLog.AddNewProductAttribute", productAttribute.Name));

                NotifySuccess(T("Admin.Catalog.Attributes.ProductAttributes.Added"));
                return(continueEditing ? RedirectToAction("Edit", new { id = productAttribute.Id }) : RedirectToAction("List"));
            }

            return(View(model));
        }
        public ActionResult Edit(ProductAttributeModel model, bool continueEditing)
        {
            var productAttribute = _productAttributeService.GetProductAttributeById(model.Id);

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

            if (ModelState.IsValid)
            {
                productAttribute = model.ToEntity(productAttribute);

                try
                {
                    _productAttributeService.UpdateProductAttribute(productAttribute);

                    UpdateLocales(productAttribute, model);
                }
                catch (Exception ex)
                {
                    ModelState.AddModelError("", ex.Message);
                    return(View(model));
                }

                _customerActivityService.InsertActivity("EditProductAttribute", T("ActivityLog.EditProductAttribute", productAttribute.Name));

                NotifySuccess(T("Admin.Catalog.Attributes.ProductAttributes.Updated"));
                return(continueEditing ? RedirectToAction("Edit", productAttribute.Id) : RedirectToAction("List"));
            }

            return(View(model));
        }
        public virtual ActionResult Create(ProductAttributeModel model, bool continueEditing)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageAttributes))
            {
                return(AccessDeniedView());
            }

            if (ModelState.IsValid)
            {
                var productAttribute = model.ToEntity();
                _productAttributeService.InsertProductAttribute(productAttribute);
                UpdateLocales(productAttribute, model);

                //activity log
                _customerActivityService.InsertActivity("AddNewProductAttribute", _localizationService.GetResource("ActivityLog.AddNewProductAttribute"), productAttribute.Name);

                SuccessNotification(_localizationService.GetResource("Admin.Catalog.Attributes.ProductAttributes.Added"));

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

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

            //If we got this far, something failed, redisplay form
            return(View(model));
        }
Пример #7
0
        /// <returns>A task that represents the asynchronous operation</returns>
        public virtual async Task <IActionResult> Create(ProductAttributeModel model, bool continueEditing)
        {
            if (!await _permissionService.AuthorizeAsync(StandardPermissionProvider.ManageAttributes))
            {
                return(AccessDeniedView());
            }

            if (ModelState.IsValid)
            {
                var productAttribute = model.ToEntity <ProductAttribute>();
                await _productAttributeService.InsertProductAttributeAsync(productAttribute);
                await UpdateLocalesAsync(productAttribute, model);

                //activity log
                await _customerActivityService.InsertActivityAsync("AddNewProductAttribute",
                                                                   string.Format(await _localizationService.GetResourceAsync("ActivityLog.AddNewProductAttribute"), productAttribute.Name), productAttribute);

                _notificationService.SuccessNotification(await _localizationService.GetResourceAsync("Admin.Catalog.Attributes.ProductAttributes.Added"));

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

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

            //prepare model
            model = await _productAttributeModelFactory.PrepareProductAttributeModelAsync(model, null, true);

            //if we got this far, something failed, redisplay form
            return(View(model));
        }
Пример #8
0
        public async Task <IActionResult> Create(ProductAttributeModel model, bool continueEditing)
        {
            if (ModelState.IsValid)
            {
                var productAttribute = model.ToEntity();
                productAttribute.SeName = SeoExtensions.GetSeName(string.IsNullOrEmpty(productAttribute.SeName) ? productAttribute.Name : productAttribute.SeName, _seoSettings);
                if (_workContext.CurrentCustomer.IsStaff())
                {
                    model.LimitedToStores  = true;
                    model.SelectedStoreIds = new string[] { _workContext.CurrentCustomer.StaffStoreId };
                }

                await _productAttributeService.InsertProductAttribute(productAttribute);

                //activity log
                await _customerActivityService.InsertActivity("AddNewProductAttribute", productAttribute.Id, _localizationService.GetResource("ActivityLog.AddNewProductAttribute"), productAttribute.Name);

                SuccessNotification(_localizationService.GetResource("Admin.Catalog.Attributes.ProductAttributes.Added"));
                return(continueEditing ? RedirectToAction("Edit", new { id = productAttribute.Id }) : RedirectToAction("List"));
            }
            //If we got this far, something failed, redisplay form
            //Stores
            await model.PrepareStoresMappingModel(null, _storeService, true);

            return(View(model));
        }
        public ActionResult Create(ProductAttributeModel model, bool continueEditing)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageCatalog))
                return AccessDeniedView();

            //decode description
            model.Description = HttpUtility.HtmlDecode(model.Description);
            foreach (var localized in model.Locales)
                localized.Description = HttpUtility.HtmlDecode(localized.Description);

            if (ModelState.IsValid)
            {
                var productAttribute = model.ToEntity();
                _productAttributeService.InsertProductAttribute(productAttribute);
                UpdateLocales(productAttribute, model);

                //activity log
                _customerActivityService.InsertActivity("AddNewProductAttribute", _localizationService.GetResource("ActivityLog.AddNewProductAttribute"), productAttribute.Name);

                SuccessNotification(_localizationService.GetResource("Admin.Catalog.Attributes.ProductAttributes.Added"));
                return continueEditing ? RedirectToAction("Edit", new { id = productAttribute.Id }) : RedirectToAction("List");
            }

            //If we got this far, something failed, redisplay form
            return View(model);
        }
Пример #10
0
        public async Task <IActionResult> Edit(ProductAttributeModel model, bool continueEditing)
        {
            var productAttribute = await _productAttributeService.GetProductAttributeById(model.Id);

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

            if (ModelState.IsValid)
            {
                productAttribute        = model.ToEntity(productAttribute);
                productAttribute.SeName = SeoExtensions.GetSeName(string.IsNullOrEmpty(productAttribute.SeName) ? productAttribute.Name : productAttribute.SeName, _seoSettings);
                if (_workContext.CurrentCustomer.IsStaff())
                {
                    model.LimitedToStores  = true;
                    model.SelectedStoreIds = new string[] { _workContext.CurrentCustomer.StaffStoreId };
                }
                await _productAttributeService.UpdateProductAttribute(productAttribute);

                //activity log
                await _customerActivityService.InsertActivity("EditProductAttribute", productAttribute.Id, _localizationService.GetResource("ActivityLog.EditProductAttribute"), productAttribute.Name);

                SuccessNotification(_localizationService.GetResource("Admin.Catalog.Attributes.ProductAttributes.Updated"));
                if (continueEditing)
                {
                    //selected tab
                    await SaveSelectedTabIndex();

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

            //If we got this far, something failed, redisplay form
            //Stores
            await model.PrepareStoresMappingModel(productAttribute, _storeService, false, _workContext.CurrentCustomer.StaffStoreId);

            // locales
            await AddLocales(_languageService, model.Locales, (locale, languageId) =>
            {
                locale.Name        = productAttribute.GetLocalized(x => x.Name, languageId, false, false);
                locale.Description = productAttribute.GetLocalized(x => x.Description, languageId, false, false);
            });

            return(View(model));
        }
Пример #11
0
        public IActionResult Create(ProductAttributeModel model, bool continueEditing)
        {
            if (ModelState.IsValid)
            {
                var productAttribute = model.ToEntity();
                _productAttributeService.InsertProductAttribute(productAttribute);

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

                SuccessNotification(_localizationService.GetResource("Admin.Catalog.Attributes.ProductAttributes.Added"));
                return(continueEditing ? RedirectToAction("Edit", new { id = productAttribute.Id }) : RedirectToAction("List"));
            }

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

            //try to get a product attribute with the specified id
            var productAttribute = _productAttributeService.GetProductAttributeById(model.Id);

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

            if (ModelState.IsValid)
            {
                productAttribute = model.ToEntity(productAttribute);
                _productAttributeService.UpdateProductAttribute(productAttribute);

                UpdateLocales(productAttribute, model);

                //activity log
                _customerActivityService.InsertActivity("EditProductAttribute",
                                                        string.Format(_localizationService.GetResource("ActivityLog.EditProductAttribute"), productAttribute.Name), productAttribute);

                _notificationService.SuccessNotification(_localizationService.GetResource("Admin.Catalog.Attributes.ProductAttributes.Updated"));

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

                //selected tab
                SaveSelectedTabName();

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

            //prepare model
            model = _productAttributeModelFactory.PrepareProductAttributeModel(model, productAttribute, true);

            //if we got this far, something failed, redisplay form
            return(View(model));
        }
        public async Task <IActionResult> Create(ProductAttributeModel model, bool continueEditing)
        {
            if (ModelState.IsValid)
            {
                var productAttribute = model.ToEntity();
                productAttribute.SeName = SeoExtensions.GetSeName(string.IsNullOrEmpty(productAttribute.SeName) ? productAttribute.Name : productAttribute.SeName, _seoSettings);
                await _productAttributeService.InsertProductAttribute(productAttribute);

                //activity log
                await _customerActivityService.InsertActivity("AddNewProductAttribute", productAttribute.Id, _localizationService.GetResource("ActivityLog.AddNewProductAttribute"), productAttribute.Name);

                SuccessNotification(_localizationService.GetResource("Admin.Catalog.Attributes.ProductAttributes.Added"));
                return(continueEditing ? RedirectToAction("Edit", new { id = productAttribute.Id }) : RedirectToAction("List"));
            }

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

            var productAttribute = _productAttributeService.GetProductAttributeById(model.Id);

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

            if (ModelState.IsValid)
            {
                productAttribute = model.ToEntity(productAttribute);

                try
                {
                    _productAttributeService.UpdateProductAttribute(productAttribute);

                    UpdateLocales(productAttribute, model);
                }
                catch (Exception exception)
                {
                    ModelState.AddModelError("", exception.Message);
                    return(View(model));
                }

                // activity log
                _customerActivityService.InsertActivity("EditProductAttribute", T("ActivityLog.EditProductAttribute", productAttribute.Name));

                NotifySuccess(T("Admin.Catalog.Attributes.ProductAttributes.Updated"));
                return(continueEditing ? RedirectToAction("Edit", productAttribute.Id) : RedirectToAction("List"));
            }

            // If we got this far, something failed, redisplay form
            return(View(model));
        }
        public async Task <IActionResult> Create(ProductAttributeModel model, bool continueEditing)
        {
            if (ModelState.IsValid)
            {
                var productAttribute = model.ToEntity();
                productAttribute.SeName = SeoExtensions.GetSeName(string.IsNullOrEmpty(productAttribute.SeName) ? productAttribute.Name : productAttribute.SeName, _seoSettings.ConvertNonWesternChars, _seoSettings.AllowUnicodeCharsInUrls, _seoSettings.SeoCharConversion);
                if (await _groupService.IsStaff(_workContext.CurrentCustomer))
                {
                    model.Stores = new string[] { _workContext.CurrentCustomer.StaffStoreId };
                }

                await _productAttributeService.InsertProductAttribute(productAttribute);

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

                Success(_translationService.GetResource("Admin.Catalog.Attributes.ProductAttributes.Added"));
                return(continueEditing ? RedirectToAction("Edit", new { id = productAttribute.Id }) : RedirectToAction("List"));
            }
            //If we got this far, something failed, redisplay form
            return(View(model));
        }
        public ActionResult Edit(ProductAttributeModel model, bool continueEditing)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageAttributes))
                return AccessDeniedView();

            var productAttribute = _productAttributeService.GetProductAttributeById(model.Id);
            if (productAttribute == null)
                //No product attribute found with the specified id
                return RedirectToAction("List");

            if (ModelState.IsValid)
            {
                productAttribute = model.ToEntity(productAttribute);
                _productAttributeService.UpdateProductAttribute(productAttribute);

                UpdateLocales(productAttribute, model);

                //activity log
                _customerActivityService.InsertActivity("EditProductAttribute", _localizationService.GetResource("ActivityLog.EditProductAttribute"), productAttribute.Name);

                SuccessNotification(_localizationService.GetResource("Admin.Catalog.Attributes.ProductAttributes.Updated"));
                return continueEditing ? RedirectToAction("Edit", productAttribute.Id) : RedirectToAction("List");
            }

            //If we got this far, something failed, redisplay form
            return View(model);
        }
Пример #17
0
        public ActionResult Create(ProductAttributeModel model, bool continueEditing)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageAttributes))
                return AccessDeniedView();

            if (ModelState.IsValid)
            {
                var productAttribute = model.ToEntity();
                _productAttributeService.InsertProductAttribute(productAttribute);
                UpdateLocales(productAttribute, model);

                //activity log
                _customerActivityService.InsertActivity("AddNewProductAttribute", _localizationService.GetResource("ActivityLog.AddNewProductAttribute"), productAttribute.Name);

                SuccessNotification(_localizationService.GetResource("Admin.Catalog.Attributes.ProductAttributes.Added"));

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

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

            }

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