/// <summary> /// A function that deletes a specific assignment milestone /// </summary> public ActionResult DeleteMilestone(int id) { Milestone milestone = (from m in db.Milestones where m.ID == id select m).FirstOrDefault(); int assignmentID = milestone.AssignmentID; int courseID = (from a in db.Assignments where a.ID == assignmentID select a.CourseID).FirstOrDefault(); #region Security SecurityRedirect redirect = accountService.VerifySecurityLevel ( auth: User.Identity.IsAuthenticated, secLevel: SecurityState.TEACHER, userID: User.Identity.GetUserId(), courseID: courseID ); if (redirect.Redirect) { return(RedirectToAction(redirect.ActionName, redirect.ControllerName)); } #endregion assignmentService.deleteMilestone(milestone); //if (milestone != null) //{ // List<Solution> solutions = (from s in db.Solutions where s.MilestoneID == id select s).ToList(); // List<Submission> submissions = (from s in db.Submission where s.MilestoneID == id select s).ToList(); // if (solutions.Count != 0) // { // IEnumerable<Solution> solutionsToDelete = solutions; // db.Solutions.RemoveRange(solutionsToDelete); // db.SaveChanges(); // } // if (submissions.Count != 0) // { // IEnumerable<Submission> submissionsToDelete = submissions; // db.Submission.RemoveRange(submissionsToDelete); // db.SaveChanges(); // } // db.Milestones.Remove(milestone); // db.SaveChanges(); //} return(RedirectToAction("TeacherAssignmentView", new { id = assignmentID })); }