public async Task <IActionResult> Create() { var model = new SpecificationAttributeModel(); //locales await AddLocales(_languageService, model.Locales); //Stores await model.PrepareStoresMappingModel(null, _storeService, false, _workContext.CurrentCustomer.StaffStoreId); return(View(model)); }
public async Task <IActionResult> Edit(SpecificationAttributeModel model, bool continueEditing) { var specificationAttribute = await _specificationAttributeService.GetSpecificationAttributeById(model.Id); if (specificationAttribute == null) { //No specification attribute found with the specified id return(RedirectToAction("List")); } if (ModelState.IsValid) { specificationAttribute = model.ToEntity(specificationAttribute); specificationAttribute.SeName = SeoExtensions.GetSeName(string.IsNullOrEmpty(specificationAttribute.SeName) ? specificationAttribute.Name : specificationAttribute.SeName, _seoSettings); if (_workContext.CurrentCustomer.IsStaff()) { model.LimitedToStores = true; model.SelectedStoreIds = new string[] { _workContext.CurrentCustomer.StaffStoreId }; } await _specificationAttributeService.UpdateSpecificationAttribute(specificationAttribute); //activity log await _customerActivityService.InsertActivity("EditSpecAttribute", specificationAttribute.Id, _localizationService.GetResource("ActivityLog.EditSpecAttribute"), specificationAttribute.Name); SuccessNotification(_localizationService.GetResource("Admin.Catalog.Attributes.SpecificationAttributes.Updated")); if (continueEditing) { //selected tab await SaveSelectedTabIndex(); return(RedirectToAction("Edit", new { id = specificationAttribute.Id })); } return(RedirectToAction("List")); } //If we got this far, something failed, redisplay form //Stores await model.PrepareStoresMappingModel(specificationAttribute, _storeService, false, _workContext.CurrentCustomer.StaffStoreId); //locales await AddLocales(_languageService, model.Locales, (locale, languageId) => { locale.Name = specificationAttribute.GetLocalized(x => x.Name, languageId, false, false); }); return(View(model)); }