From 5d31cc2d3c8b1dc0ea5520947af5a85cb107fd42 Mon Sep 17 00:00:00 2001 From: Tokk Date: Sat, 20 Jun 2020 10:36:23 +0200 Subject: [PATCH] Bulk-Fragenerfassung; --- .../Controllers/QuestionsController.cs | 14 +++++++++++--- .../Views/Questions/Create.cshtml | 12 ++++++++---- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/MultipleChoiceTrainer/Controllers/QuestionsController.cs b/MultipleChoiceTrainer/Controllers/QuestionsController.cs index b5019b1..758258a 100644 --- a/MultipleChoiceTrainer/Controllers/QuestionsController.cs +++ b/MultipleChoiceTrainer/Controllers/QuestionsController.cs @@ -45,7 +45,7 @@ namespace MultipleChoiceTrainer.Controllers // more details, see http://go.microsoft.com/fwlink/?LinkId=317598. [HttpPost] [ValidateAntiForgeryToken] - public async Task Create(QuestionViewModel question) + public async Task Create(QuestionViewModel question, bool anotherQuestion) { question.CreationDate = DateTime.Now; if (ModelState.IsValid) @@ -55,8 +55,16 @@ namespace MultipleChoiceTrainer.Controllers _context.Add(question as Question); await _context.SaveChangesAsync(); - var section = _context.Sections.FirstOrDefault(s => s.Id == question.SectionId); - return RedirectToAction(nameof(Index), "Home", new { categoryId = section.CategoryId }); + + if(anotherQuestion) + { + return RedirectToAction(nameof(Create), new { sectionId = question.SectionId }); + } + else + { + var section = _context.Sections.FirstOrDefault(s => s.Id == question.SectionId); + return RedirectToAction(nameof(Index), "Home", new { categoryId = section.CategoryId }); + } } ViewData["Section"] = _context.Sections.Include(e => e.Category).FirstOrDefault(s => s.Id == question.SectionId); ViewData["CountChoiceFields"] = CountChoiceFields; diff --git a/MultipleChoiceTrainer/Views/Questions/Create.cshtml b/MultipleChoiceTrainer/Views/Questions/Create.cshtml index 27a6bdb..b8f97f1 100644 --- a/MultipleChoiceTrainer/Views/Questions/Create.cshtml +++ b/MultipleChoiceTrainer/Views/Questions/Create.cshtml @@ -54,14 +54,18 @@ Abbrechen + +
+ + +
+ -
- Back to List -
- @section Scripts { @{await Html.RenderPartialAsync("_ValidationScriptsPartial");} }