Пример #1
0
        public async Task <IActionResult> EditPollConfirmed(RawPollViewModel model)
        {
            var poll = await PollContext.Polls.FindAsync(model.PollId);

            PollContext.Polls.Remove(poll);
            await CreatePollAsync(model);

            return(RedirectToAction("ListPolls"));
        }
Пример #2
0
        private async Task CreatePollAsync(RawPollViewModel vm)
        {
            var poll = new Poll
            {
                Question  = vm.Question,
                StartDate = vm.StartDate.ToUniversalTime(),
                EndDate   = vm.EndDate.ToUniversalTime(),
            };

            poll.Choices = new ChoiceConverter(poll).GetChoices(vm.Choices);

            PollContext.Polls.Add(poll);
            await PollContext.SaveChangesAsync();
        }
Пример #3
0
        public async Task <IActionResult> CreatePollConfirmed(RawPollViewModel vm)
        {
            await CreatePollAsync(vm);

            return(RedirectToAction("ListNewPolls", "Poll"));
        }