public ActionResult AddNewAppointmentSubmit(Appointment app) { if (!Authorize()) { return(RedirectToAction("RedirectByUser", "Home")); } User current = (User)Session["CurrentUser"]; DateTime temp = new DateTime(app.Date.Year, app.Date.Month, app.Date.Day, Convert.ToInt32(Request.Form["hour"]), Convert.ToInt32(Request.Form["minu"]), 00); app.Date = temp; if (app.Date < DateTime.Now) { ViewBag.appexist = "לא ניתן להוסיף תורים לזמן שעבר"; return(View("AddNewAppointments")); } app.DoctorName = docDal.Users.FirstOrDefault <Doctor>(x => x.UserName == current.UserName).FirstName; if (appDal.Appointments.FirstOrDefault <Appointment>(x => x.Date == app.Date && app.DoctorName == x.DoctorName) != null) { ViewBag.appexist = "תור קיים"; return(View("AddNewAppointments")); } appDal.Appointments.Add(app); appDal.SaveChanges(); return(View("DoctorPage")); }
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 ChooseAppointment(string DoctorName, DateTime date) { if (!Authorize()) { return(RedirectToAction("RedirectByUser", "Home")); } Appointment chosen = new Appointment { DoctorName = DoctorName, Date = date }; PatientDal pdal = new PatientDal(); User currentUser = (User)Session["CurrentUser"]; Patient currentPatient = pdal.Patients.FirstOrDefault <Patient>(x => x.UserName == currentUser.UserName); AppointmentDal appDal = new AppointmentDal(); Appointment update = appDal.Appointments.FirstOrDefault <Appointment>(x => x.Date == chosen.Date && x.DoctorName == chosen.DoctorName); update.PatientUserName = currentPatient.UserName; appDal.SaveChanges(); return(View("PatientPage")); }