public ActionResult AssignUserDropdown(int index = 0)
 {
     AppointmentHostViewModel ViewModel = new AppointmentHostViewModel();
     ViewBag.index = index;
     ViewBag.userList = new SelectList(db.SystemUsers.Where(u => !u.UserRoles.Any(r => r.RoleName.StartsWith("Student"))), "UserId", "UserName");
     return PartialView(ViewModel);
 }
 public ActionResult Edit(AppointmentHostViewModel ViewModel)
 {
     if (ModelState.IsValid)
     {
         AppointmentHost appointmenthost = db.AppointmentHosts.Find(ViewModel.host.id);
         db.Entry(appointmenthost).CurrentValues.SetValues(ViewModel.host);
         appointmenthost.SystemUsers.Clear();
         if (ViewModel.users != null)
         {
             foreach (var user in ViewModel.users)
             {
                 appointmenthost.SystemUsers.Add(db.SystemUsers.Find(user.UserId));
             }
         }
         db.SaveChanges();
         return RedirectToAction("Index");
     }
     return View(ViewModel);
 }
 //
 // GET: /AppointmentHost/Edit/5
 public ActionResult Edit(int id = 0)
 {
     AppointmentHost appointmenthost = db.AppointmentHosts.Find(id);
     ViewBag.userList = new SelectList(db.SystemUsers.Where(u => !u.UserRoles.Any(r => r.RoleName.StartsWith("Student"))), "UserId", "UserName");
     if (appointmenthost == null)
     {
         Session["FlashMessage"] = "Appointment Host not found.";
         return RedirectToAction("Index");
     }
     AppointmentHostViewModel ViewModel = new AppointmentHostViewModel();
     ViewModel.host = appointmenthost;
     ViewModel.users = appointmenthost.SystemUsers.ToList();
     return View(ViewModel);
 }