Esempio n. 1
0
        public ActionResult AvailableDoctor(FormCollection fc)
        {
            ERPDataContext           dc     = new ERPDataContext();
            DocScheduleQuery         qdata  = new DocScheduleQuery();
            DocScheduleStatus        Doc    = new DocScheduleStatus();
            List <DocScheduleStatus> status = new List <DocScheduleStatus>();

            if (ModelState.IsValid)
            {
                qdata.Date       = Convert.ToDateTime(fc["Date"]);
                qdata.Department = Convert.ToString(fc["Department"]);
                var result = dc.Schedules.Where(x => x.Start.Date == qdata.Date.Date).FirstOrDefault();
                if (result != null)
                {
                    var data = from ds in dc.DoctorSchedules
                               join doc in dc.Doctors on ds.DoctorID equals doc.DoctorID
                               where ds.EventID == result.EventID
                               select new
                    {
                        DoctorID   = doc.DoctorID,
                        Department = doc.Department,
                        DoctorName = doc.FirstName + doc.LastName,
                    };

                    var doctor = from doc in data
                                 where (doc.Department == qdata.Department)
                                 select new
                    {
                        Date       = result.Start,
                        DoctorID   = doc.DoctorID,
                        Department = doc.Department,
                        DoctorName = doc.DoctorName
                    };
                    if (doctor != null)
                    {
                        foreach (var v in doctor)
                        {
                            Doc.DoctorID   = v.DoctorID;
                            Doc.Date       = qdata.Date.ToString("MM/dd/yyyy");
                            Doc.Department = v.Department;
                            Doc.DoctorName = v.DoctorName;
                            Doc.Status     = result.Subject;
                        }
                        status.Add(Doc);
                        return(View(status));
                    }
                    else
                    {
                        ViewBag.NoDoctor = "No Doctor is Available";
                        return(Redirect("/MakeAppointment/AppointmentIndex"));
                    }
                }
                ViewBag.NoSchedule = "No Schedule Availble";
                return(Redirect("/MakeAppointment/AppointmentIndex"));
            }
            return(View());
        }
        //AvailableDoctors
        public JsonResult AvailableDoctors(string Date, string Department)
        {
            ERPDataContext         dc      = new ERPDataContext();
            List <AvailableDoctor> Doctors = new List <AvailableDoctor>();
            DocScheduleQuery       qdata   = new DocScheduleQuery();

            if (Date != null & Department != null)
            {
                qdata.Date       = Convert.ToDateTime(Date);
                qdata.Department = Department;
                var result = dc.Schedules.Where(x => x.Start.Date == qdata.Date.Date).FirstOrDefault();
                if (result != null)
                {
                    var data = from ds in dc.DoctorSchedules
                               join doc in dc.Doctors on ds.DoctorID equals doc.DoctorID
                               where ds.EventID == result.EventID
                               select new
                    {
                        DoctorID   = doc.DoctorID,
                        Department = doc.Department,
                        DoctorName = doc.FirstName + doc.LastName,
                    };

                    var doctor = from doc in data
                                 where (doc.Department == qdata.Department)
                                 select new
                    {
                        DoctorID   = doc.DoctorID,
                        DoctorName = doc.DoctorName
                    };
                    if (doctor != null)
                    {
                        foreach (var v in doctor)
                        {
                            AvailableDoctor a = new AvailableDoctor();
                            a.DoctorID   = v.DoctorID;
                            a.DoctorName = v.DoctorName;
                            Doctors.Add(a);
                        }
                        return(Json(Doctors, JsonRequestBehavior.AllowGet));
                    }
                    return(Json(false, JsonRequestBehavior.AllowGet));
                }
                return(Json(false, JsonRequestBehavior.AllowGet));
            }
            return(Json(false, JsonRequestBehavior.AllowGet));
        }