public ActionResult Edit(int?id) { tblAppointmentSlot t = db.tblAppointmentSlots.SingleOrDefault(x => x.intSlotID == id); AppointmentSlotModel P = new AppointmentSlotModel() { SlotID = t.intSlotID, DoctorID = (int)t.intDoctorID, ClinicID = (int)t.intClinicID, Date = (DateTime)t.dtmDate, StartTime = (DateTime)t.dtmStartTime, EndTime = (DateTime)t.dtmEndTime, Status = t.strStatus, }; return(View(P)); }
public ActionResult Edit(AppointmentSlotModel am) { tblAppointmentSlot a = db.tblAppointmentSlots.SingleOrDefault(x => x.intSlotID == am.SlotID); if (a != null) { a.intSlotID = am.SlotID; a.intDoctorID = am.DoctorID; a.intClinicID = am.ClinicID; a.dtmDate = am.Date; a.dtmStartTime = am.StartTime; a.dtmEndTime = am.EndTime; a.strStatus = am.Status; db.SaveChanges(); } return(RedirectToAction("Index")); }
public ActionResult BookAppoitment(BookModel M) { tblAppointment ap = new tblAppointment(); ap.intSlotID = M.SlotID; ap.intMemberID = Convert.ToInt32(Session["memberid"]);// Session here ap.intPatientAge = M.PatientAge; ap.strNotes = M.Notes; ap.strOldCaseNo = M.OldCaseNo; ap.strPatientGender = M.PatientGender; ap.strPatientName = M.PatientName; ap.dtmAppotimentTakenTime = DateTime.Now; ap.blnIsNewCase = M.IsNewCase; db.tblAppointments.Add(ap); db.SaveChanges(); tblAppointmentSlot s = db.tblAppointmentSlots.SingleOrDefault(x => x.intSlotID == M.SlotID); if (s != null) { s.strStatus = "Booked"; db.SaveChanges(); //Mail Code Here String em = Session["email"].ToString(); String sub = "Your Appointment Booked"; String det = "\nAppointment ID " + ap.intAppointmentID; det += "\nFor :" + ap.strPatientName; SmtpClient cl = new SmtpClient("smtp.gmail.com", 587); cl.Credentials = new NetworkCredential("*****@*****.**", "fake123456"); cl.EnableSsl = true; MailMessage mg = new MailMessage("*****@*****.**", em, sub, det); cl.Send(mg); //If you get error in mail comment cl.send line } return(RedirectToAction("Index")); }
public ActionResult Create(AppointmentSlotModel AS, FormCollection frm) { String gap = frm["Gap"]; tblAppointmentSlot a = new tblAppointmentSlot(); a.intSlotID = AS.SlotID; a.intDoctorID = Convert.ToInt32(Session["doctorid"]); a.intClinicID = AS.ClinicID; a.dtmDate = AS.Date; a.dtmStartTime = AS.StartTime; a.dtmEndTime = AS.EndTime; a.dtmStartTime = a.dtmDate; a.dtmStartTime = a.dtmStartTime.Value.AddHours(AS.StartTime.Hour); a.dtmStartTime = a.dtmStartTime.Value.AddMinutes(AS.StartTime.Minute); a.dtmEndTime = a.dtmDate.Value.AddHours(AS.EndTime.Hour); a.dtmEndTime = a.dtmEndTime.Value.AddMinutes(AS.EndTime.Minute); a.strStatus = AS.Status; DateTime st = a.dtmStartTime.Value; DateTime end = a.dtmEndTime.Value; while (st <= end) { DateTime en = st.AddMinutes(Convert.ToInt32(gap)); a.dtmStartTime = st; a.dtmEndTime = en;// a.dtmEndTime.Value.AddMinutes(); db.tblAppointmentSlots.Add(a); db.SaveChanges(); st = en; } return(RedirectToAction("Index")); }