public Quiz PatchRenameQuiz(int id, string newName)
        {
            Quiz quiz = _quizContext
                        .Quizzes
                        .First(q => q.Id == id);

            quiz.Title = newName;
            _quizContext.Update(quiz);
            _quizContext.SaveChanges();

            return(quiz);
        }
        public async Task <IActionResult> Edit(int id, [Bind("Id,Nome,Email,Senha,Foto")] Jogador jogador)
        {
            if (id != jogador.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(jogador);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!JogadorExists(jogador.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(jogador));
        }
        public async Task <IActionResult> Edit(int id, [Bind("Id,Pergunta,Opcao_a,Opcao_b,Opcao_c,Opcao_d,Resposta_certa")] Questao questao)
        {
            if (id != questao.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(questao);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!QuestaoExists(questao.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(questao));
        }
Exemple #4
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Name")] Category category)
        {
            if (id != category.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(category);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CategoryExists(category.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(category));
        }
Exemple #5
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Statement,CategoryId")] Question question)
        {
            if (id != question.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(question);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!QuestionExists(question.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CategoryId"] = new SelectList(_context.Categories, "Id", "Id", question.CategoryId);
            return(View(question));
        }
Exemple #6
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,JogadorId,QuestaoId,Resposta")] RespostaJogador respostaJogador)
        {
            if (id != respostaJogador.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(respostaJogador);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!RespostaJogadorExists(respostaJogador.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["JogadorId"] = new SelectList(_context.Jogador, "Id", "Id", respostaJogador.JogadorId);
            ViewData["QuestaoId"] = new SelectList(_context.Questao, "Id", "Id", respostaJogador.QuestaoId);
            return(View(respostaJogador));
        }
Exemple #7
0
        public Quiz RenameQuiz(int quizId, string newName)
        {
            var x = _context.Quizes.Include(q => q.Questions)
                    .ThenInclude(a => a.Answers)
                    .SingleOrDefault(i => i.Id == quizId);

            x.Title = newName;
            _context.Update(x);
            _context.SaveChanges();

            return(x);
        }