public void EmailBooking(AppointmentModel app)
        {
            try
            {
                Email_Api       emailApi     = new Email_Api();
                Appointment_Api aptms        = new Appointment_Api();
                var             apppointment = aptms.GetAllAppointments().Where(a => a.appointment_ID == app.appointment_ID).First();
                var             patients     = emailApi.GetPatientsAppointments();

                Admin_Api adminApi   = new Admin_Api();
                var       patDetails = (adminApi.GetAllPatients()).Where(p => p.pid == apppointment.paitent_ID).First();

                MailMessage mailMessage = new MailMessage("*****@*****.**", patDetails.emailID);
                // Specify the email body
                mailMessage.Body = "Dear Patient you have booked appointment with Doctor " + app.doctorName +
                                   " Appointment ID is " + app.appointment_ID + " appointment time is " + app.timings;
                mailMessage.Subject = "Success Booking";
                SmtpClient smtpClient = new SmtpClient("smtp.gmail.com", 587);
                smtpClient.Credentials = new System.Net.NetworkCredential()
                {
                    UserName = "******",
                    Password = "******"
                };
                smtpClient.EnableSsl = true;
                smtpClient.Send(mailMessage);
            }
            catch (Exception ex)
            {
                Utils.Logging(ex, 2);
            }
        }
        public JsonResult fillPatientList(string text)
        {
            Appointment_Api   app     = new Appointment_Api();
            TreatmentRoom_Api roomApi = new TreatmentRoom_Api();
            var model     = roomApi.GetAllTreatmentRoomRecs().Where(t => (t.date == DateTime.Parse(text) && t.isBooked == true)).GroupBy(g => g.patient_ID).Select(s => s.First()).ToList();
            var allAptmts = app.GetAllAppointments();

            var apps = allAptmts.Where(a => a.appointment_Date > DateTime.Now).GroupBy(g => g.paitent_ID).Select(s => s.First()).ToList();

            TreatmentRoomModel trModelPats = new TreatmentRoomModel();

            TreatmentRoomModel trModel = new TreatmentRoomModel();

            //var allApts = app.GetAllAppointments();

            foreach (var p in model)
            {
                trModelPats.patientDropDown.Add(new SelectListItem
                {
                    Text  = p.patientFirstName,
                    Value = Convert.ToString(p.patient_ID)
                });
            }

            foreach (var p in apps)
            {
                trModel.patientDropDown.Add(new SelectListItem
                {
                    Text  = p.patientName,
                    Value = Convert.ToString(p.paitent_ID)
                });
            }

            trModel.patientDropDown = (from t in trModel.patientDropDown
                                       where trModelPats.patientDropDown.All(o => o.Text != t.Text) select t).ToList();
            List <SelectListItem> patientList = new List <SelectListItem>();

            foreach (var p in trModel.patientDropDown)
            {
                patientList.Add(p);
            }

            foreach (var t in trModel.patientDropDown)
            {
                if ((GetApptsForRooms(Convert.ToInt32(t.Value))).Count() == 0)
                {
                    patientList.Remove(t);
                }
            }

            return(Json(patientList, JsonRequestBehavior.AllowGet));
        }