public void sendEmail(AppointmentViewModal modal) { try { MailMessage mm = new MailMessage(); mm.From = new MailAddress("*****@*****.**", "Conestoga Hospital"); mm.To.Add(_patientService.GetPatientByPatientNo(modal.PatientNo).EmailId); mm.Subject = "Appointment Confirmation"; mm.Body += "<br />Hello " + modal.PatientName + " (" + modal.PatientNo + "),<br /><br />"; mm.Body += "Your appointment with doctor " + modal.DoctorName + " (" + modal.Speciality + ") has been booked for " + modal.AppointmentDate.ToString("dd/MM/yyyy") + " from " + modal.AptStartTime.ToString("hh:mm tt") + " to " + modal.AptEndTime.ToString("hh:mm tt") + "."; mm.IsBodyHtml = true; SmtpClient smtp = new SmtpClient(); smtp.Host = "smtp.gmail.com"; smtp.EnableSsl = true; smtp.UseDefaultCredentials = true; smtp.Port = 587; smtp.Credentials = new System.Net.NetworkCredential("*****@*****.**", "khanakhajana@123"); smtp.Send(mm); } catch (Exception ex) { string Mail_msg = "Mail can't be sent because of server problem: "; // Mail_msg += ex.Message; //Response.Write(Mail_msg); // Label11.Text = Mail_msg; } }
public JsonResult GetAppointmentSlots(string date, string doctorId) //public JsonResult GetAppointmentSlots() { DateTime startTime = Convert.ToDateTime("09:00 AM"); DateTime endTime; var appontmentList = _doctorService.getAppointmentListByDoctorAndDate(Convert.ToDateTime(date), Convert.ToInt32(doctorId)); List <AppointmentViewModal> slots = new List <AppointmentViewModal>(); do { endTime = startTime.AddMinutes(30); AppointmentViewModal appointmentViewModal = new AppointmentViewModal(); appointmentViewModal.StartTime = startTime.ToString("hh:mm tt"); appointmentViewModal.EndTime = endTime.ToString("hh:mm tt"); if (appontmentList != null && appontmentList.Count != 0) { foreach (var appointment in appontmentList) { if (startTime == appointment.StartTime) { appointmentViewModal.IsAvailable = false; appointmentViewModal.BackgroundColor = "#d9534f"; break; } else { appointmentViewModal.IsAvailable = true; appointmentViewModal.BackgroundColor = "#5cb85c"; } } } else { appointmentViewModal.IsAvailable = true; appointmentViewModal.BackgroundColor = "#5cb85c"; } slots.Add(appointmentViewModal); startTime = endTime; } while (endTime != Convert.ToDateTime("05:00 PM")); return(new JsonResult { Data = new { Status = "Success", data = slots }, JsonRequestBehavior = JsonRequestBehavior.AllowGet }); }
public AppointmentViewModal getAppointmentById(int appointmentId) { AppointmentViewModal modal = new AppointmentViewModal(); modal = (from apt in context.Appointments join pat in context.Patients on apt.PatientNo equals pat.PatientNo join doc in context.Doctors on apt.DoctorId equals doc.DoctorId join usr in context.Users on doc.UserId equals usr.UserId join spec in context.Specialites on doc.SpecialityId equals spec.SpecialityId where apt.AppointmentId == appointmentId select new AppointmentViewModal() { AppointmentId = apt.AppointmentId, PatientNo = pat.PatientNo, PatientName = pat.FName + " " + pat.LName, AptStartTime = apt.StartTime, AptEndTime = apt.EndTime, DoctorName = usr.FName + " " + usr.LName, Speciality = spec.SpecialityName, AppointmentDate = apt.AppointmentDate }).FirstOrDefault(); return(modal); }