Beispiel #1
0
        public IActionResult Create()
        {
            ViewBag.AllLanguages = _languageService.GetAllLanguages(true);
            var model = new PollModel();

            //default values
            model.Published      = true;
            model.ShowOnHomePage = true;
            //Stores
            model.PrepareStoresMappingModel(null, false, _storeService);
            //locales
            AddLocales(_languageService, model.Locales);
            //ACL
            model.PrepareACLModel(null, false, _customerService);
            return(View(model));
        }
Beispiel #2
0
        public async Task <IActionResult> Edit(PollModel model, bool continueEditing)
        {
            var poll = await _pollService.GetPollById(model.Id);

            if (poll == null)
            {
                //No poll found with the specified id
                return(RedirectToAction("List"));
            }

            if (ModelState.IsValid)
            {
                poll = model.ToEntity(poll, _dateTimeHelper);
                await _pollService.UpdatePoll(poll);

                SuccessNotification(_localizationService.GetResource("Admin.ContentManagement.Polls.Updated"));

                if (continueEditing)
                {
                    //selected tab
                    await SaveSelectedTabIndex();

                    return(RedirectToAction("Edit", new { id = poll.Id }));
                }
                return(RedirectToAction("List"));
            }

            //If we got this far, something failed, redisplay form
            ViewBag.AllLanguages = _languageService.GetAllLanguages(true);

            //Store
            await model.PrepareStoresMappingModel(poll, _storeService, true);

            //ACL
            await model.PrepareACLModel(poll, true, _customerService);

            //locales
            await AddLocales(_languageService, model.Locales, (locale, languageId) =>
            {
                locale.Name = poll.GetLocalized(x => x.Name, languageId, false, false);
            });

            return(View(model));
        }
Beispiel #3
0
        public async Task <IActionResult> Create()
        {
            ViewBag.AllLanguages = await _languageService.GetAllLanguages(true);

            var model = new PollModel
            {
                //default values
                Published      = true,
                ShowOnHomePage = true
            };
            //Stores
            await model.PrepareStoresMappingModel(null, _storeService, false);

            //locales
            await AddLocales(_languageService, model.Locales);

            //ACL
            await model.PrepareACLModel(null, false, _customerService);

            return(View(model));
        }
Beispiel #4
0
        public IActionResult Create(PollModel model, bool continueEditing)
        {
            if (ModelState.IsValid)
            {
                var poll = model.ToEntity();
                _pollService.InsertPoll(poll);

                SuccessNotification(_localizationService.GetResource("Admin.ContentManagement.Polls.Added"));
                return(continueEditing ? RedirectToAction("Edit", new { id = poll.Id }) : RedirectToAction("List"));
            }

            //If we got this far, something failed, redisplay form
            ViewBag.AllLanguages = _languageService.GetAllLanguages(true);
            //Stores
            model.PrepareStoresMappingModel(null, true, _storeService);
            //locales
            AddLocales(_languageService, model.Locales);
            //ACL
            model.PrepareACLModel(null, true, _customerService);

            return(View(model));
        }