//DELETE ASSIGN public ActionResult RemoveTrainee(int trainee_course_id) { Trainee_Course trainee_Course = db.Trainee_Course.Find(trainee_course_id); int courseId = trainee_Course.Cours.Id; db.Trainee_Course.Remove(trainee_Course); db.SaveChanges(); return(RedirectToAction("EditCourses", "Staff", new { id = courseId })); }
//Assign public ActionResult AssignCourse(int CourseId, int Trainee) { Trainee trainee = db.Trainees.Find(Trainee); Cours course = db.Courses.Find(CourseId); if (trainee != null) { //trainers.Topics.Add(topic); //topic.Trainers.Add(trainer); Trainee_Course trainee_Course = new Trainee_Course(); trainee_Course.Cours = course; trainee_Course.Trainee = trainee; db.Trainee_Course.Add(trainee_Course); db.SaveChanges(); } return(RedirectToAction("EditCourses", new { id = course.Id })); }