// returns null if the user is not currently an instructor of this class public InstructorRosterEntry TestInstructorRoster(InstructorRosterEntry Instructor) { InstructorRosterEntry temp = context.InstructorRosterEntries.FirstOrDefault(u => (u.InstuctorID == Instructor.InstuctorID) && (u.ClassID == Instructor.ClassID)); return temp; }
public void DropInstructorRoster(InstructorRosterEntry Instructor) { InstructorRosterEntry i = context.InstructorRosterEntries.FirstOrDefault((e => (e.ClassID == Instructor.ClassID) && (e.InstuctorID == Instructor.InstuctorID))); context.InstructorRosterEntries.Remove(i); }
public ActionResult AddNewInstructor(FormCollection formValues) { int cid = (int)Session["ClassID"]; var uid = Int32.Parse(formValues["UserID"]); // avoid duplicate entries InstructorRosterEntry temp = new InstructorRosterEntry { InstuctorID = uid, ClassID = cid }; if (repository.TestInstructorRoster(temp) == null) repository.AddInstructor(cid, uid); TempData["message"] = string.Format("User {0} has been added to the Instructors of class {1}.", temp.InstuctorID, temp.ClassID); return RedirectToAction("EditInstructors/" + cid.ToString()); }
public void AddInstructor(int cid, int uid) { var newInstructor = new InstructorRosterEntry { InstuctorID = uid, ClassID = cid }; context.InstructorRosterEntries.Add(newInstructor); context.SaveChanges(); }
public ActionResult DropInstructor(int id) { int cid = (int)Session["ClassID"]; int userID = id; InstructorRosterEntry temp = new InstructorRosterEntry { InstuctorID = userID, ClassID = cid }; repository.DropInstructorRoster(temp); repository.SaveChanges(); TempData["message"] = string.Format("User {0} has been dropped from Class {1}.", temp.InstuctorID, temp.ClassID); return RedirectToAction("EditInstructors/" + cid.ToString()); }