Bulk-Fragenerfassung;
This commit is contained in:
@@ -45,7 +45,7 @@ namespace MultipleChoiceTrainer.Controllers
|
|||||||
// more details, see http://go.microsoft.com/fwlink/?LinkId=317598.
|
// more details, see http://go.microsoft.com/fwlink/?LinkId=317598.
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
[ValidateAntiForgeryToken]
|
[ValidateAntiForgeryToken]
|
||||||
public async Task<IActionResult> Create(QuestionViewModel question)
|
public async Task<IActionResult> Create(QuestionViewModel question, bool anotherQuestion)
|
||||||
{
|
{
|
||||||
question.CreationDate = DateTime.Now;
|
question.CreationDate = DateTime.Now;
|
||||||
if (ModelState.IsValid)
|
if (ModelState.IsValid)
|
||||||
@@ -55,8 +55,16 @@ namespace MultipleChoiceTrainer.Controllers
|
|||||||
|
|
||||||
_context.Add(question as Question);
|
_context.Add(question as Question);
|
||||||
await _context.SaveChangesAsync();
|
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["Section"] = _context.Sections.Include(e => e.Category).FirstOrDefault(s => s.Id == question.SectionId);
|
||||||
ViewData["CountChoiceFields"] = CountChoiceFields;
|
ViewData["CountChoiceFields"] = CountChoiceFields;
|
||||||
|
|||||||
@@ -54,14 +54,18 @@
|
|||||||
<button type="submit" class="btn btn-outline-primary"><i class="fas fa-save"></i> Speichern</button>
|
<button type="submit" class="btn btn-outline-primary"><i class="fas fa-save"></i> Speichern</button>
|
||||||
<a asp-action="Index" asp-controller="Home" asp-route-categoryId="@ViewBag.Section.CategoryId" class="btn btn-outline-danger"><i class="fas fa-times"></i> Abbrechen</a>
|
<a asp-action="Index" asp-controller="Home" asp-route-categoryId="@ViewBag.Section.CategoryId" class="btn btn-outline-danger"><i class="fas fa-times"></i> Abbrechen</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="form-check">
|
||||||
|
<input class="form-check-input" type="checkbox" value="true" checked id="anotherQuestion" name="anotherQuestion">
|
||||||
|
<label class="form-check-label" for="anotherQuestion">
|
||||||
|
Im Anschluss eine weitere Frage erfassen
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div>
|
|
||||||
<a asp-action="Index">Back to List</a>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
@section Scripts {
|
@section Scripts {
|
||||||
@{await Html.RenderPartialAsync("_ValidationScriptsPartial");}
|
@{await Html.RenderPartialAsync("_ValidationScriptsPartial");}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user