public ActionResult NewReport()
        {
            if (Convert.ToString(Session["key"]) != "doctor")
            {
                return(RedirectToAction("Login", "Home"));
            }

            Doctor_Api doctorApi    = new Doctor_Api();
            var        appointments = doctorApi.GetDocApntment_Api((int)Session["UserId"]).Where(a => a.appointment_Date < DateTime.Now);

            Admin_Api        adminApi = new Admin_Api();
            var              pats     = adminApi.GetAllPatients();
            AppointmentModel docapts  = new AppointmentModel();

            foreach (var d in pats)
            {
                docapts.dropDown.Add(new SelectListItem
                {
                    Text  = d.firstName,
                    Value = Convert.ToString(d.pid)
                });
            }

            return(View("~/Views/Doctor/RequestReport.cshtml", docapts));
        }
        public ActionResult ViewPatRoomBooking()
        {
            if (Convert.ToString(Session["key"]) != "admin")
            {
                return(RedirectToAction("Login", "Home"));
            }
            Admin_Api adminApi = new Admin_Api();
            var       patients = adminApi.GetAllPatients();

            List <SelectListItem> dropDownpatients = new List <SelectListItem>();

            foreach (var p in patients)
            {
                dropDownpatients.Add(new SelectListItem
                {
                    Text  = p.firstName,
                    Value = Convert.ToString(p.pid)
                });
            }
            AccountModel model = new AccountModel();

            model.patientdropDown = dropDownpatients;

            if (model != null)
            {
                return(View("~/Views/Administrator/AdminViewPatientsForRoom.cshtml", model));
            }
            return(RedirectToAction("ViewRooms"));
        }
        public ActionResult ViewAddAccountDetail()
        {
            if (Convert.ToString(Session["key"]) != "admin")
            {
                return(RedirectToAction("Login", "Home"));
            }

            Admin_Api adminApi = new Admin_Api();
            var       patients = adminApi.GetAllPatients();

            List <SelectListItem> dropDownpatients = new List <SelectListItem>();

            foreach (var p in patients)
            {
                dropDownpatients.Add(new SelectListItem
                {
                    Text  = p.firstName,
                    Value = Convert.ToString(p.pid)
                });
            }

            AccountModel model = new AccountModel();

            model.patientdropDown = dropDownpatients;
            model.AppointmentIDDropDown.Add(new SelectListItem {
                Text = "-Select-", Value = "-Select-"
            });
            return(View("~/Views/Administrator/AdminAddViewBilling.cshtml", model));
        }
        public ActionResult viewNewBooking()
        {
            if (Convert.ToString(Session["key"]) != "admin")
            {
                return(RedirectToAction("Login", "Home"));
            }

            Admin_Api adminApi = new Admin_Api();
            var       patients = adminApi.GetAllPatients();

            TreatmentRoomModel trModel = new TreatmentRoomModel();

            foreach (var p in patients)
            {
                trModel.patientDropDown.Add(new SelectListItem {
                    Text  = p.firstName,
                    Value = Convert.ToString(p.pid)
                });
            }

            TreatmentRoom_Api roomApi  = new TreatmentRoom_Api();
            var bookedRooms            = roomApi.GetAllTreatmentRooms().Where(t => t.isBooked == true).Select(t => t.patient_ID);
            AppointmentTimings timings = new AppointmentTimings();

            trModel.appointmentTimings = timings.timingsDropDown;

            return(View("~/Views/Administrator/AdminBookRoom.cshtml", trModel));
        }
        public ActionResult ViewCreateNewReport()
        {
            if (Convert.ToString(Session["key"]) != "labIncharge")
            {
                return(RedirectToAction("Login", "Home"));
            }

            Patient_Api patientApi = new Patient_Api();
            //ViewBag.GetPatientsList = new SelectList(patientApi.GetPaitentsList());
            Admin_Api   adminApi = new Admin_Api();
            var         pats     = adminApi.GetAllPatients();
            ReportModel repts    = new ReportModel();

            foreach (var d in pats)
            {
                repts.dropDown.Add(new SelectListItem
                {
                    Text  = d.firstName,
                    Value = Convert.ToString(d.pid)
                });
            }

            //ViewBag.GetPatientsList = docapts;
            return(View("~/Views/LabIncharge/LabInchargeCreateReport.cshtml", repts));
        }
        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 ActionResult ViewPatients()
        {
            Admin_Api        adminApi = new Admin_Api();
            var              pats     = adminApi.GetAllPatients();
            AppointmentModel docapts  = new AppointmentModel();

            foreach (var d in pats)
            {
                docapts.dropDown.Add(new SelectListItem
                {
                    Text  = d.firstName,
                    Value = Convert.ToString(d.pid)
                });
            }
            return(View("~/Views/Doctor/ViewPatientList.cshtml", docapts));
        }
        public ActionResult ViewPatients()
        {
            if (Convert.ToString(Session["key"]) != "admin")
            {
                return(RedirectToAction("Login", "Home"));
            }

            Admin_Api adminGetAllPatientsApi = new Admin_Api();
            var       model = adminGetAllPatientsApi.GetAllPatients();

            if (model != null)
            {
                return(View("~/Views/Administrator/AdminViewPatients.cshtml", model));
            }
            error.ErrorMessage = "Unable to Get Patient Details";
            return(View("~/Views/Error.cshtml", error));
        }
        public ActionResult BookNewAppointment(AppointmentModel apmnt = null)
        {
            if (Convert.ToString(Session["key"]) != "doctor")
            {
                return(RedirectToAction("Login", "Home"));
            }

            if (apmnt.timings != null)
            {
                Doctor_Api doc_Api = new Doctor_Api();
                apmnt.doctor_ID = (int)Session["UserId"]; //5006;
                apmnt.date      = DateTime.Now;           //booking date
                var newBooking = doc_Api.BookDocApnmt_Api(apmnt);
                List <AppointmentModel> newAppointment = new List <AppointmentModel>();
                newBooking.canCancel = true;
                newAppointment.Add(newBooking);
                if (newBooking != null)
                {
                    return(View("~/Views/Doctor/DoctorViewAppointments.cshtml", newAppointment));
                }
                else
                {
                    return(View("~/Views/Error.cshtml"));
                }
            }
            else
            {
                AppointmentModel appModel = new AppointmentModel();
                Admin_Api        adminApi = new Admin_Api();
                var patients = adminApi.GetAllPatients();

                foreach (var p in patients)
                {
                    appModel.dropDown.Add(new SelectListItem {
                        Text  = p.firstName,
                        Value = Convert.ToString(p.pid)
                    });
                }

                return(View("~/Views/Doctor/DoctorBookAppointment.cshtml", appModel));
            }
        }
        public ActionResult SelectPatients()
        {
            if (Convert.ToString(Session["key"]) != "nurse")
            {
                return(RedirectToAction("Login", "Home"));
            }

            Admin_Api        adminApi = new Admin_Api();
            var              pats     = adminApi.GetAllPatients();
            AppointmentModel docapts  = new AppointmentModel();

            foreach (var d in pats)
            {
                docapts.dropDown.Add(new SelectListItem
                {
                    Text  = d.firstName,
                    Value = Convert.ToString(d.pid)
                });
            }

            return(View("~/Views/Nurse/ViewPatientList.cshtml", docapts));
        }
        public ActionResult ViewForPayments()
        {
            if (Convert.ToString(Session["key"]) != "admin")
            {
                return(RedirectToAction("Login", "Home"));
            }

            Admin_Api        adminGetAllPatientsApi = new Admin_Api();
            var              model = adminGetAllPatientsApi.GetAllPatients();
            AppointmentModel app   = new AppointmentModel();

            foreach (var p in model)
            {
                app.dropDown.Add(new SelectListItem {
                    Text = p.firstName, Value = Convert.ToString(p.pid)
                });
            }
            if (model != null)
            {
                return(View("~/Views/Administrator/ViewPatientsForPayments.cshtml", app));
            }
            error.ErrorMessage = "Unable to Get Patient Details";
            return(View("~/Views/Error.cshtml", error));
        }
        public ActionResult GetRoleDetails(NotificationsModel notification)
        {
            if (Convert.ToString(Session["key"]) != "admin")
            {
                return(RedirectToAction("Login", "Home"));
            }

            Admin_Api          adminApi = new Admin_Api();
            NotificationsModel model    = new NotificationsModel();

            ViewBag.dropdownModel = null;

            if (notification.Notifications.Equals("Doctors"))
            {
                var persons = adminApi.GetAllDoctor();
                foreach (var p in persons)
                {
                    model.personDetails.Add(new SelectListItem {
                        Text  = p.firstName,
                        Value = Convert.ToString(p.pid)
                    });
                }
                ViewBag.dropdownModel = "Doctors";
            }
            else if (notification.Notifications.Equals("Patients"))
            {
                var persons = adminApi.GetAllPatients();
                foreach (var p in persons)
                {
                    model.personDetails.Add(new SelectListItem
                    {
                        Text  = p.firstName,
                        Value = Convert.ToString(p.pid)
                    });
                }
                ViewBag.dropdownModel = "Patients";
            }
            else if (notification.Notifications.Equals("Nurses"))
            {
                var persons = adminApi.GetAllNurses();
                foreach (var p in persons)
                {
                    model.personDetails.Add(new SelectListItem
                    {
                        Text  = p.firstName,
                        Value = Convert.ToString(p.pid)
                    });
                }
                ViewBag.dropdownModel = "Nurses";
            }
            else if (notification.Notifications.Equals("LabIncharges"))
            {
                var persons = adminApi.GetAllLabIncharges();
                foreach (var p in persons)
                {
                    model.personDetails.Add(new SelectListItem
                    {
                        Text  = p.firstName,
                        Value = Convert.ToString(p.pid)
                    });
                }
                ViewBag.dropdownModel = "LabIncharges";
            }

            return(View("~/Views/Administrator/AdminAddNotifications.cshtml", model));
        }