public ActionResult Create(CreateAssignmentViewModel newAssignment, int id) { newAssignment.courseID = id; if (aService.createAssignment(newAssignment)) { return(RedirectToAction("Index", "Assignments", new { id = id })); } else { ModelState.AddModelError("", "Could not add the assignment!"); return(RedirectToAction("Create", "Assignments")); } }
public void testCreateAssignment() { // arrange var a1 = new CreateAssignmentViewModel { name = "Mooshak 2.0", description = "Make Mooshak free for us", startDate = new DateTime(2016, 05, 05, 00, 00, 00), endDate = new DateTime(2016, 06, 06, 23, 59, 59), solution = "free" }; // act var beforeadd = _service.getAllAssignments(); var result = _service.createAssignment(a1); var afteradd = _service.getAllAssignments(); // assert Assert.AreEqual(6, beforeadd.assignments.Count); Assert.AreEqual(7, afteradd.assignments.Count); }