コード例 #1
0
 // 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;
 }
コード例 #2
0
 public void DropInstructorRoster(InstructorRosterEntry Instructor)
 {
     InstructorRosterEntry i = context.InstructorRosterEntries.FirstOrDefault((e => (e.ClassID == Instructor.ClassID) && (e.InstuctorID == Instructor.InstuctorID)));
     context.InstructorRosterEntries.Remove(i);
 }
コード例 #3
0
        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());
        }
コード例 #4
0
        public void AddInstructor(int cid, int uid)
        {
            var newInstructor = new InstructorRosterEntry { InstuctorID = uid, ClassID = cid };

            context.InstructorRosterEntries.Add(newInstructor);
            context.SaveChanges();
        }
コード例 #5
0
        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());
        }