public async Task <ActionResult> Create(Teacher teacher) { try { // TODO: Add insert logic here if (!ModelState.IsValid) { throw new Exception("Validation Error"); } Teacher result = await _teacherRepo.Add(teacher); if (result == null) { throw new Exception("Invalid Entry"); } return(RedirectToAction(nameof(Index))); } catch (Exception ex) { Debug.WriteLine("Create is unable to save." + ex.Message); ModelState.AddModelError("CreateError", "Create mislukt. " + ex.Message); return(View(teacher)); //foutieve view teruggeven } }