public async Task <IActionResult> AddAssignmentSubmit(AddAssignmentModel model) { if (ModelState.IsValid && model.DueDateTime is DateTime && model.DueDateTime > DateTime.Now) { var user = await GetCurrentUserAsync(); if (user is TeacherAccount) { var sc = _schoolClasses.GetByTeacher(user.Id); var assignment = new Assignment() { SchoolClass = sc, DateTime = DateTime.Now, DueDate = model.DueDateTime, Name = model.AssignmentName }; _assignments.Add(assignment); return(RedirectToAction("Index")); } } return(RedirectToAction("Error", "Home")); }