public async Task <IActionResult> EditCorrectChoice(Guid id, QuestionCreateEditViewModel vm)
        {
            if (id != vm.Question.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    await _uow.Questions.UpdateAsync(vm.Question);

                    await _uow.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!QuestionExists(vm.Question.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }

                return(RedirectToAction("Details", "Questions", new { id = vm.Question.Id }));
            }

            vm.CorrectChoices =
                new SelectList(await _uow.Choices.GetAllAsync(), nameof(Choice.Id), nameof(Choice.Value));
            vm.Quizzes = new SelectList(await _uow.Quizzes.GetAllAsync(), nameof(Quiz.Id), nameof(Quiz.Title));
            return(View(vm));
        }
        public async Task <IActionResult> Create(QuestionCreateEditViewModel vm)
        {
            if (ModelState.IsValid)
            {
                vm.Question.Id = Guid.NewGuid();
                _uow.Questions.Add(vm.Question);
                await _uow.SaveChangesAsync();

                return(RedirectToAction("Details", "Quizzes", new { id = vm.Question.QuizId }));
            }

            vm.CorrectChoices =
                new SelectList(await _uow.Choices.GetAllAsync(), nameof(Choice.Id), nameof(Choice.Value));
            vm.Quizzes = new SelectList(await _uow.Quizzes.GetAllAsync(), nameof(Quiz.Id), nameof(Quiz.Title));
            return(View(vm));
        }
        // GET: Questions/Create
        public IActionResult Create(Guid?quiz)
        {
            var vm = new QuestionCreateEditViewModel
            {
                CorrectChoices = new SelectList(_uow.Choices.GetAll(), nameof(Choice.Id), nameof(Choice.Value)),
                Quizzes        = new SelectList(_uow.Quizzes.GetAll(), nameof(Quiz.Id), nameof(Quiz.Title))
            };

            if (quiz.HasValue)
            {
                vm.Question = new Question
                {
                    QuizId = quiz.Value
                };
            }
            return(View(vm));
        }
        // GET: Questions/Edit/5
        public async Task <IActionResult> Edit(Guid?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            var vm = new QuestionCreateEditViewModel()
            {
                Question = await _uow.Questions.FirstOrDefaultAsync(id.Value)
            };

            if (vm.Question == null)
            {
                return(NotFound());
            }

            vm.CorrectChoices =
                new SelectList(await _uow.Choices.GetAllAsync(), nameof(Choice.Id), nameof(Choice.Value));
            vm.Quizzes = new SelectList(await _uow.Quizzes.GetAllAsync(), nameof(Quiz.Id), nameof(Quiz.Title));
            return(View(vm));
        }