Bulk-Fragenerfassung;

This commit is contained in:
2020-06-20 10:36:23 +02:00
parent 0c25e6cf89
commit 5d31cc2d3c
2 changed files with 19 additions and 7 deletions

View File

@@ -45,7 +45,7 @@ namespace MultipleChoiceTrainer.Controllers
// more details, see http://go.microsoft.com/fwlink/?LinkId=317598.
[HttpPost]
[ValidateAntiForgeryToken]
public async Task<IActionResult> Create(QuestionViewModel question)
public async Task<IActionResult> 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;