示例#1
0
        public ActionResult Index(string massage)
        {
            var viewModel = new HospitalListViewModel
            {
                Hospitals = _context.Hospitals.Where(h => h.IsApproved),
                Massage   = massage
            };

            return(View((User.IsInRole(UserRoles.CanApproveAndDeleteRecord)) ? "HospitalList" : "HospitalListReadOnly", viewModel));
        }
        //public CountInTimeFrame hospitalSchedulesWithPatient(DateTime date, string TimeFrame,
        //                                    int doctorid)
        //{
        //    using (CaremeDBContext context = new CaremeDBContext())
        //    {
        //        DateTime scheduledate = date;
        //        var day = scheduledate.DayOfWeek.ToString();

        //        CountInTimeFrame citf_data = new CountInTimeFrame();
        //        citf_data.TimeFrame = TimeFrame;

        //        DateTime? combined = null;

        //        List<tbSchedule> schedules = context.tbSchedules.Where(a => a.IsDeleted != true
        //                        && a.DoctorID == doctorid).Where(daysQuery(day)).ToList(); //date
        //        List<HospitalListViewModel> hlistvm = new List<HospitalListViewModel>();
        //        foreach (var item in schedules)
        //        {
        //            var newdate = scheduledate.ToShortDateString();//tochange
        //            var time = item.Fromtime.Value.ToShortTimeString();
        //            combined = DateTime.Parse(newdate + " " + time);

        //            HospitalListViewModel hlvm = new HospitalListViewModel();
        //            hlvm.fromTime = item.Fromtime;
        //            hlvm.toTime = item.Totime;
        //            hlvm.patientCount = context.tbAppointments.Where(a => a.IsDeleted != true
        //                                    && a.DoctorId == item.DoctorID
        //                                    && a.HospitalId == item.HospitalID && a.Day == day && a.AppointmentDateTime == combined).Count();
        //            hlvm.hospitalId = item.HospitalID;
        //            hlvm.hospitalName = item.HospitalName;
        //            hlvm.appointmentDateTime = combined;
        //            hlvm.scheduleID = item.ID;
        //            hlistvm.Add(hlvm);
        //        }
        //        citf_data.hospitalList = hlistvm;
        //        var nextday = date.AddDays(1).Date;
        //        citf_data.totalPatientCount = context.tbAppointments.Where(a => a.IsDeleted != true).Where(a => a.DoctorId == doctorid
        //                                                && a.Day == day && a.AppointmentDateTime >= date.Date && a.AppointmentDateTime <= nextday).Count();

        //        return citf_data;
        //    }
        //}

        public CountInTimeFrame hospitalSchedulesWithPatient(DateTime date, string TimeFrame,
                                                             int doctorid)
        {
            using (CaremeDBContext context = new CaremeDBContext())
            {
                DateTime scheduledate = date;
                var      day          = scheduledate.DayOfWeek.ToString();

                CountInTimeFrame citf_data = new CountInTimeFrame();
                citf_data.TimeFrame = TimeFrame;

                DateTime?combined = null;

                //List<tbSchedule> schedules = context.tbSchedules.Where(a => a.IsDeleted != true
                //                && a.DoctorID == doctorid).Where(daysQuery(day)).ToList(); //date



                date = date.Date;
                var dateto = date.AddDays(1);
                List <tbScheduleData> schedules = context.tbScheduleDatas.Where(a => a.IsDeleted != true &&
                                                                                a.DoctorID == doctorid && a.AppointmentDatetime >= date && a.AppointmentDatetime <= dateto).ToList();


                List <HospitalListViewModel> hlistvm = new List <HospitalListViewModel>();
                foreach (var item in schedules)
                {
                    //var newdate = scheduledate.ToShortDateString();//tochange
                    //var time = item.Fromtime.Value.ToShortTimeString();
                    //combined = DateTime.Parse(newdate + " " + time);

                    HospitalListViewModel hlvm = new HospitalListViewModel();
                    hlvm.fromTime     = item.Fromtime;
                    hlvm.toTime       = item.Totime;
                    hlvm.patientCount = context.tbAppointments.Where(a => a.IsDeleted != true &&
                                                                     a.DoctorId == item.DoctorID &&
                                                                     a.HospitalId == item.HospitalID && a.AppointmentDateTime == item.AppointmentDatetime).Count();
                    hlvm.hospitalId          = item.HospitalID;
                    hlvm.hospitalName        = item.HospitalName;
                    hlvm.appointmentDateTime = item.AppointmentDatetime;
                    hlvm.scheduleID          = item.ID;
                    hlistvm.Add(hlvm);
                }
                citf_data.hospitalList = hlistvm;
                var nextday = date.AddDays(1).Date;
                citf_data.totalPatientCount = context.tbAppointments.Where(a => a.IsDeleted != true).Where(a => a.DoctorId == doctorid &&
                                                                                                           a.AppointmentDateTime >= date.Date && a.AppointmentDateTime <= nextday).Count();

                return(citf_data);
            }
        }