public void AddInvalidAssignmentFails() { var newAssignment = new Assignment() { //No assignment name! Ahhhhhh!!! PossiblePoints = 30, DueDate = DateTime.Parse("7/7/2015"), AssignmentDescription = "This was added via a test." }; var response = _assignmentManager.AddAssignment(newAssignment); Assert.IsFalse(response.Success); }
public void CanAddValidAssignment() { var assignment = new Assignment() { CourseId = 1, AssignmentName = "Busy Work", PossiblePoints = 30, DueDate = DateTime.Parse("7/7/2015"), AssignmentDescription = "You should do this stuff." }; _repo.AddAssignment(assignment); }
public void AddValidAssignmentIsSuccess() { var newAssignment = new Assignment() { CourseId = 1, AssignmentName = "MegaTest", PossiblePoints = 30, DueDate = DateTime.Parse("7/7/2015"), AssignmentDescription = "This was added via a test." }; var response = _assignmentManager.AddAssignment(newAssignment); Assert.IsTrue(response.Success); }
public void AddAssignment(Assignment newAssignment) { using (var cn = new SqlConnection(Settings.GetConnectionString())) { var p = new DynamicParameters(); p.Add("CourseId", newAssignment.CourseId); p.Add("AssignmentName", newAssignment.AssignmentName); p.Add("PossiblePoints", newAssignment.PossiblePoints); p.Add("DueDate", newAssignment.DueDate); p.Add("AssignmentDescription", newAssignment.AssignmentDescription); var result = cn.Execute("spAddAssignment", p, commandType: CommandType.StoredProcedure); } }
public void CanDeleteAssignment() { var assignment = new Assignment() { CourseId = 1, AssignmentName = "Busy Work", PossiblePoints = 30, DueDate = DateTime.Parse("7/7/2015"), AssignmentDescription = "You should do this stuff." }; var x = _repo.GetGradebookForCourseId(1).GroupBy(a=>a.AssignmentId).ToList().Count; _repo.AddAssignment(assignment); // should be 14 according to sample data _repo.DeleteAssignment(14); Assert.AreEqual(_repo.GetGradebookForCourseId(1).GroupBy(a=>a.AssignmentId).ToList().Count, x); }
public Response AddAssignment(Assignment newAssignment) { var response = new Response(); var validation = IsValidAssignment(newAssignment); if (!validation.Success) { response.Message = validation.Message; return response; } try { _assignmentRepository.AddAssignment(newAssignment); response.Success = true; } catch (Exception ex) { response.Message = ex.Message; } return response; }
public ActionResult AddAssignment(AddAssignmentVM vm) { if (vm.DueDate > vm.CourseDetails.EndDate || vm.DueDate < vm.CourseDetails.StartDate) { ModelState.AddModelError("DateRange", "The due date must be between the start date and end date of the course."); } if (!ModelState.IsValid) { var courseResponse = _courseManager.GetCourseDetailsById(vm.CourseId); if (courseResponse.Success) { vm.CourseDetails = courseResponse.Data; return View(vm); } else { ViewBag.ErrorMsg = courseResponse.Message; return View("Error"); } } var newAssignment = new Assignment() { AssignmentDescription = vm.AssignmentDescription, AssignmentName = vm.AssignmentName, CourseId = vm.CourseId, DueDate = vm.DueDate, PossiblePoints = vm.PossiblePoints }; var response = _assignmentManager.AddAssignment(newAssignment); if (response.Success) { return RedirectToAction("Gradebook", new { id = newAssignment.CourseId }); } else { ViewBag.ErrorMsg = response.Message; return View("Error"); } }
public ActionResult AssignmentInformation(AddAssignmentVM vm) { if (!ModelState.IsValid) { var courseResponse = _courseManager.GetCourseDetailsById(vm.CourseId); if (courseResponse.Success) { vm.CourseDetails = courseResponse.Data; return View(vm); } else { ViewBag.ErrorMsg = courseResponse.Message; return View("Error"); } } var deleteResponse = _assignmentManager.DeleteAssignment(vm.AssignmentId, _assignmentManager.GetGradebook(vm.CourseId).GradebookListItems); if (!deleteResponse.Success) { ViewBag.ErrorMsg = deleteResponse.Message; return View("Error"); } var newAssignment = new Assignment() { AssignmentDescription = vm.AssignmentDescription, AssignmentName = vm.AssignmentName, CourseId = vm.CourseId, DueDate = vm.DueDate, PossiblePoints = vm.PossiblePoints }; var response = _assignmentManager.AddAssignment(newAssignment); if (response.Success) { return RedirectToAction("Gradebook", new { id = newAssignment.CourseId }); } else { ViewBag.ErrorMsg = response.Message; return View("Error"); } }
public Response IsValidAssignment(Assignment assignment) { var response = new Response(); if (string.IsNullOrEmpty(assignment.AssignmentName)) { response.Message = "Name is required."; return response; } if (assignment.DueDate == DateTime.MinValue) { response.Message = "Due Date is required."; return response; } if (string.IsNullOrEmpty(assignment.AssignmentDescription)) { response.Message = "Description is required."; return response; } response.Success = true; return response; }
public void CannotAddInvalidAssignment() { var assignment = new Assignment() { CourseId = 1, //No assignment name! Oh no! PossiblePoints = 30, DueDate = DateTime.Parse("7/7/2015"), AssignmentDescription = "Do it do it!." }; _repo.AddAssignment(assignment); }
public void AddAssignment(Assignment newAssignment) { return; }