public IActionResult AddAttribute(InteractiveFormAttributeModel model, bool continueEditing) { if (!_permissionService.Authorize(StandardPermissionProvider.ManageInteractiveForm)) { return(AccessDeniedView()); } if (ModelState.IsValid) { var form = _interactiveFormService.GetFormById(model.FormId); if (form == null) { return(RedirectToAction("List")); } var attribute = model.ToEntity(); attribute.Locales = UpdateLocales(attribute, model); form.FormAttributes.Add(attribute); _interactiveFormService.UpdateForm(form); _customerActivityService.InsertActivity("InteractiveFormEdit", attribute.Id, _localizationService.GetResource("ActivityLog.InteractiveFormAddAttribute"), attribute.Name); SuccessNotification(_localizationService.GetResource("Admin.Promotions.InteractiveForms.Attribute.Added")); return(continueEditing ? RedirectToAction("EditAttribute", new { formId = form.Id, aid = attribute.Id }) : RedirectToAction("Edit", new { id = form.Id })); } return(View(model)); }
public IActionResult EditAttribute(string formId, InteractiveFormAttributeModel model, bool continueEditing) { var form = _interactiveFormService.GetFormById(formId); if (form == null) { return(RedirectToAction("List")); } var attribute = form.FormAttributes.FirstOrDefault(x => x.Id == model.Id); if (attribute == null) { return(RedirectToAction("List")); } try { if (ModelState.IsValid) { attribute = model.ToEntity(attribute); _interactiveFormService.UpdateForm(form); _customerActivityService.InsertActivity("InteractiveFormEdit", attribute.Id, _localizationService.GetResource("ActivityLog.InteractiveFormUpdateAttribute"), attribute.Name); SuccessNotification(_localizationService.GetResource("Admin.Promotions.InteractiveForms.Attribute.Updated")); return(continueEditing ? RedirectToAction("EditAttribute", new { formId = form.Id, aid = attribute.Id }) : RedirectToAction("Edit", new { id = form.Id })); } return(View(model)); } catch (Exception exc) { ErrorNotification(exc); return(RedirectToAction("Edit", new { id = form.Id })); } }
public IActionResult AddAttribute(string formId) { InteractiveFormAttributeModel model = new InteractiveFormAttributeModel(); model.FormId = formId; AddLocales(_languageService, model.Locales); return(View(model)); }
public async Task <IActionResult> AddAttribute(string formId) { InteractiveFormAttributeModel model = new InteractiveFormAttributeModel { FormId = formId }; await AddLocales(_languageService, model.Locales); return(View(model)); }
public IActionResult AddAttribute(string formId) { if (!_permissionService.Authorize(StandardPermissionProvider.ManageInteractiveForm)) { return(AccessDeniedView()); } InteractiveFormAttributeModel model = new InteractiveFormAttributeModel(); model.FormId = formId; AddLocales(_languageService, model.Locales); return(View(model)); }
public async Task <IActionResult> AddAttribute(InteractiveFormAttributeModel model, bool continueEditing) { if (ModelState.IsValid) { var form = await _interactiveFormService.GetFormById(model.FormId); if (form == null) { return(RedirectToAction("List")); } var attribute = model.ToEntity(); form.FormAttributes.Add(attribute); await _interactiveFormService.UpdateForm(form); await _customerActivityService.InsertActivity("InteractiveFormEdit", attribute.Id, _translationService.GetResource("ActivityLog.InteractiveFormAddAttribute"), attribute.Name); Success(_translationService.GetResource("admin.marketing.InteractiveForms.Attribute.Added")); return(continueEditing ? RedirectToAction("EditAttribute", new { formId = form.Id, aid = attribute.Id }) : RedirectToAction("Edit", new { id = form.Id })); } return(View(model)); }
public static InteractiveForm.FormAttribute ToEntity(this InteractiveFormAttributeModel model, InteractiveForm.FormAttribute destination) { return(model.MapTo(destination)); }
public static InteractiveForm.FormAttribute ToEntity(this InteractiveFormAttributeModel model) { return(model.MapTo <InteractiveFormAttributeModel, InteractiveForm.FormAttribute>()); }
protected virtual List <LocalizedProperty> UpdateLocales(InteractiveForm.FormAttribute attribute, InteractiveFormAttributeModel model) { List <LocalizedProperty> localized = new List <LocalizedProperty>(); foreach (var local in model.Locales) { localized.Add(new LocalizedProperty() { LanguageId = local.LanguageId, LocaleKey = "Name", LocaleValue = local.Name }); } return(localized); }