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 }));
            }
        }
Beispiel #2
0
        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 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));
        }