public IActionResult Create(ContactAttributeModel model, bool continueEditing) { if (!_permissionService.Authorize(StandardPermissionProvider.ManageAttributes)) { return(AccessDeniedView()); } if (ModelState.IsValid) { var contactAttribute = model.ToEntity(); contactAttribute.CustomerRoles = model.SelectedCustomerRoleIds != null?model.SelectedCustomerRoleIds.ToList() : new List <string>(); contactAttribute.Locales = UpdateAttributeLocales(contactAttribute, model); contactAttribute.Stores = model.SelectedStoreIds != null?model.SelectedStoreIds.ToList() : new List <string>(); _contactAttributeService.InsertContactAttribute(contactAttribute); //activity log _customerActivityService.InsertActivity("AddNewContactAttribute", contactAttribute.Id, _localizationService.GetResource("ActivityLog.AddNewContactAttribute"), contactAttribute.Name); SuccessNotification(_localizationService.GetResource("Admin.Catalog.Attributes.ContactAttributes.Added")); return(continueEditing ? RedirectToAction("Edit", new { id = contactAttribute.Id }) : RedirectToAction("List")); } //If we got this far, something failed, redisplay form //Stores PrepareStoresMappingModel(model, null, true); //ACL PrepareAclModel(model, null, true); return(View(model)); }
public virtual async Task <ContactAttribute> InsertContactAttributeModel(ContactAttributeModel model) { var contactAttribute = model.ToEntity(); await _contactAttributeService.InsertContactAttribute(contactAttribute); //activity log await _customerActivityService.InsertActivity("AddNewContactAttribute", contactAttribute.Id, _localizationService.GetResource("ActivityLog.AddNewContactAttribute"), contactAttribute.Name); return(contactAttribute); }
public virtual ContactAttribute UpdateContactAttributeModel(ContactAttribute contactAttribute, ContactAttributeModel model) { contactAttribute = model.ToEntity(contactAttribute); SaveConditionAttributes(contactAttribute, model); _contactAttributeService.UpdateContactAttribute(contactAttribute); //activity log _customerActivityService.InsertActivity("EditContactAttribute", contactAttribute.Id, _localizationService.GetResource("ActivityLog.EditContactAttribute"), contactAttribute.Name); return(contactAttribute); }
public virtual async Task <ContactAttribute> UpdateContactAttributeModel(ContactAttribute contactAttribute, ContactAttributeModel model) { contactAttribute = model.ToEntity(contactAttribute); await SaveConditionAttributes(contactAttribute, model); await _contactAttributeService.UpdateContactAttribute(contactAttribute); //activity log await _customerActivityService.InsertActivity("EditContactAttribute", contactAttribute.Id, _translationService.GetResource("ActivityLog.EditContactAttribute"), contactAttribute.Name); return(contactAttribute); }
public IActionResult Edit(ContactAttributeModel model, bool continueEditing) { if (!_permissionService.Authorize(StandardPermissionProvider.ManageAttributes)) { return(AccessDeniedView()); } var contactAttribute = _contactAttributeService.GetContactAttributeById(model.Id); if (contactAttribute == null) { //No contact attribute found with the specified id return(RedirectToAction("List")); } if (ModelState.IsValid) { contactAttribute = model.ToEntity(contactAttribute); SaveConditionAttributes(contactAttribute, model); contactAttribute.CustomerRoles = model.SelectedCustomerRoleIds != null?model.SelectedCustomerRoleIds.ToList() : new List <string>(); contactAttribute.Locales = UpdateAttributeLocales(contactAttribute, model); contactAttribute.Stores = model.SelectedStoreIds != null?model.SelectedStoreIds.ToList() : new List <string>(); _contactAttributeService.UpdateContactAttribute(contactAttribute); //activity log _customerActivityService.InsertActivity("EditContactAttribute", contactAttribute.Id, _localizationService.GetResource("ActivityLog.EditContactAttribute"), contactAttribute.Name); SuccessNotification(_localizationService.GetResource("Admin.Catalog.Attributes.ContactAttributes.Updated")); if (continueEditing) { //selected tab SaveSelectedTabIndex(); return(RedirectToAction("Edit", new { id = contactAttribute.Id })); } return(RedirectToAction("List")); } //If we got this far, something failed, redisplay form //Stores PrepareStoresMappingModel(model, contactAttribute, true); //ACL PrepareAclModel(model, contactAttribute, false); return(View(model)); }