public ActionResult GetDoctorsByJson() { if (!Authorize()) { return(RedirectToAction("RedirectByUser", "Home")); } User currentUser = (User)Session["CurrentUser"]; DoctorDal docDal = new DoctorDal(); List <string> doctors = (from doc in docDal.Users select doc.UserName).ToList <string>(); for (int i = 0; i < doctors.Count; i++) { doctors[i] = des.Decrypt(doctors[i], "Galit@19"); } Thread.Sleep(1000); return(Json(doctors, JsonRequestBehavior.AllowGet)); }
public ActionResult CancelAppointment(string DoctorName, DateTime date) { if (!Authorize()) { return(RedirectToAction("RedirectByUser", "Home")); } Appointment chosen = new Appointment { DoctorName = DoctorName, Date = date }; AppointmentDal appDal = new AppointmentDal(); Appointment update = appDal.Appointments.FirstOrDefault <Appointment>(x => x.Date == chosen.Date && x.DoctorName == chosen.DoctorName); update.PatientUserName = null; appDal.SaveChanges(); DoctorDal dctDal = new DoctorDal(); return(View("PatientPage")); }
public ActionResult RedirectByUser() { if (Session["CurrentUser"] != null) { User currentUsr = (User)(Session["CurrentUser"]); DoctorDal docDal = new DoctorDal(); if (docDal.Users.FirstOrDefault <Doctor>(x => x.UserName == currentUsr.UserName) != null) { return(RedirectToAction("DoctorPage", "Doctor")); } else { return(RedirectToAction("PatientPage", "Patient")); } } else { TempData["notAuthorized"] = "You have no permission!"; return(RedirectToAction("HomePage")); } }