public async Task <IActionResult> Create(CategoryModel model, bool continueEditing) { if (ModelState.IsValid) { if (_workContext.CurrentCustomer.IsStaff()) { model.LimitedToStores = true; model.SelectedStoreIds = new string[] { _workContext.CurrentCustomer.StaffStoreId }; } var category = await _categoryViewModelService.InsertCategoryModel(model); SuccessNotification(_localizationService.GetResource("Admin.Catalog.Categories.Added")); return(continueEditing ? RedirectToAction("Edit", new { id = category.Id }) : RedirectToAction("List")); } //If we got this far, something failed, redisplay form model = await _categoryViewModelService.PrepareCategoryModel(model, null, _workContext.CurrentCustomer.StaffStoreId); //ACL await model.PrepareACLModel(null, true, _customerService); //Stores await model.PrepareStoresMappingModel(null, _storeService, true, _workContext.CurrentCustomer.StaffStoreId); return(View(model)); }
public IActionResult Create(CategoryModel model, bool continueEditing) { if (ModelState.IsValid) { var category = _categoryViewModelService.InsertCategoryModel(model); SuccessNotification(_localizationService.GetResource("Admin.Catalog.Categories.Added")); return(continueEditing ? RedirectToAction("Edit", new { id = category.Id }) : RedirectToAction("List")); } //If we got this far, something failed, redisplay form model = _categoryViewModelService.PrepareCategoryModel(model, null); //ACL model.PrepareACLModel(null, true, _customerService); //Stores model.PrepareStoresMappingModel(null, true, _storeService); return(View(model)); }
public async Task <IActionResult> Create(CategoryModel model, bool continueEditing) { if (ModelState.IsValid) { if (await _groupService.IsStaff(_workContext.CurrentCustomer)) { model.Stores = new string[] { _workContext.CurrentCustomer.StaffStoreId }; } var category = await _categoryViewModelService.InsertCategoryModel(model); Success(_translationService.GetResource("Admin.Catalog.Categories.Added")); return(continueEditing ? RedirectToAction("Edit", new { id = category.Id }) : RedirectToAction("List")); } //If we got this far, something failed, redisplay form model = await _categoryViewModelService.PrepareCategoryModel(model, null, _workContext.CurrentCustomer.StaffStoreId); return(View(model)); }