Exemple #1
0
        public IActionResult Create(InteractiveFormModel model, bool continueEditing)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageInteractiveForm))
            {
                return(AccessDeniedView());
            }

            if (ModelState.IsValid)
            {
                var form = model.ToEntity();
                form.CreatedOnUtc = DateTime.UtcNow;
                form.Locales      = UpdateLocales(form, model);

                _interactiveFormService.InsertForm(form);
                _customerActivityService.InsertActivity("InteractiveFormAdd", form.Id, _localizationService.GetResource("ActivityLog.InteractiveFormAdd"), form.Name);

                SuccessNotification(_localizationService.GetResource("Admin.Promotions.InteractiveForms.Added"));
                return(continueEditing ? RedirectToAction("Edit", new { id = form.Id }) : RedirectToAction("List"));
            }
            //locales
            AddLocales(_languageService, model.Locales);
            //available email accounts
            foreach (var ea in _emailAccountService.GetAllEmailAccounts())
            {
                model.AvailableEmailAccounts.Add(ea.ToModel());
            }
            return(View(model));
        }
        public async Task <IActionResult> Create(InteractiveFormModel model, bool continueEditing)
        {
            if (ModelState.IsValid)
            {
                var form = model.ToEntity();
                form.CreatedOnUtc = DateTime.UtcNow;

                await _interactiveFormService.InsertForm(form);

                await _customerActivityService.InsertActivity("InteractiveFormAdd", form.Id, _translationService.GetResource("ActivityLog.InteractiveFormAdd"), form.Name);

                Success(_translationService.GetResource("admin.marketing.InteractiveForms.Added"));
                return(continueEditing ? RedirectToAction("Edit", new { id = form.Id }) : RedirectToAction("List"));
            }
            //locales
            await AddLocales(_languageService, model.Locales);

            //available email accounts
            foreach (var ea in await _emailAccountService.GetAllEmailAccounts())
            {
                model.AvailableEmailAccounts.Add(ea.ToModel());
            }
            return(View(model));
        }