コード例 #1
0
        public List <TimeSlotDetailsForAppointmentModel> GetTimeSlotToBind(List <TrinityTimeSlotModel> tsModel)
        {
            try
            {
                tsModel.Where(c => c.Category == "Morning").Select(c => { c.CategoryID = 1; return(c); }).ToList();

                tsModel.Where(c => c.Category == "Afternoon").Select(c => { c.CategoryID = 2; return(c); }).ToList();

                tsModel.Where(c => c.Category == "Evening").Select(c => { c.CategoryID = 3; return(c); }).ToList();

                var grpList = tsModel.OrderBy(x => x.CategoryID).ToList().OrderBy(st => st.StartTime).ToList()
                              .GroupBy(t => t.Category)
                              .Select(grp => grp.ToList())
                              .ToList();
                TimeSlotDetailsForAppointmentModel        TimeSlotDetailsForAppointment = new TimeSlotDetailsForAppointmentModel();
                List <TimeSlotForAppointmentModel>        lstTimeSlotForAppointment     = new List <TimeSlotForAppointmentModel>();
                TimeSlotForAppointmentModel               TimeSlotForAppointment        = new TimeSlotForAppointmentModel();
                List <TimeSlotDetailsForAppointmentModel> appTimeSlot = new List <TimeSlotDetailsForAppointmentModel>();
                foreach (var item in grpList)
                {
                    TimeSlotDetailsForAppointment = new TimeSlotDetailsForAppointmentModel();
                    TimeSlotDetailsForAppointment.TimeSlot_Category = item[0].Category;
                    lstTimeSlotForAppointment = new List <TimeSlotForAppointmentModel>();
                    foreach (var tm in item)
                    {
                        TimeSlotForAppointment                      = new TimeSlotForAppointmentModel();
                        TimeSlotForAppointment.TimeSlotID           = tm.Timeslot_ID;
                        TimeSlotForAppointment.TimeSlot_Description = tm.Description;
                        TimeSlotForAppointment.Slot_Start_Time      = tm.StartTime.Value.Hours.ToString("00") + ":" + tm.StartTime.Value.Minutes.ToString("00");
                        TimeSlotForAppointment.Slot_End_Time        = tm.EndTime.Value.Hours.ToString("00") + ":" + tm.EndTime.Value.Minutes.ToString("00");

                        if (tm.MaximumSupervisee > tm.App_cnt)
                        {
                            TimeSlotForAppointment.IsTimeSlotAvailable = true;
                        }
                        else
                        {
                            TimeSlotForAppointment.IsTimeSlotAvailable = false;
                        }
                        lstTimeSlotForAppointment.Add(TimeSlotForAppointment);
                    }
                    TimeSlotDetailsForAppointment.TimeSlot_Appointment = lstTimeSlotForAppointment;
                    appTimeSlot.Add(TimeSlotDetailsForAppointment);
                }

                return(appTimeSlot);
            }
            catch (Exception ex)
            {
                Log.Error(ex.Message);
                Log.Error(ex.InnerException);
                return(null);
            }
        }
コード例 #2
0
        public IEnumerable <TimeSlotDetailsForAppointmentModel> GetAppointmentTimeSlots(string dayOfWeek)
        {
            using (AppointmentBookingRepository repo = new AppointmentBookingRepository())
            {
                IEnumerable <TimeSlotModel> timeslot = repo.GetAppointmentTimeSlots(dayOfWeek);

                List <TimeSlotDetailsForAppointmentModel> appTimeSlot = new List <TimeSlotDetailsForAppointmentModel>();

                TimeSlotDetailsForAppointmentModel TimeSlotDetailsForAppointment = new TimeSlotDetailsForAppointmentModel();

                TimeSlotForAppointmentModel        TimeSlotForAppointment    = new TimeSlotForAppointmentModel();
                List <TimeSlotForAppointmentModel> lstTimeSlotForAppointment = new List <TimeSlotForAppointmentModel>();

                var grpList = timeslot
                              .GroupBy(t => t.TimeSlot_Category)
                              .Select(grp => grp.ToList())
                              .ToList();

                foreach (var item in grpList)
                {
                    TimeSlotDetailsForAppointment = new TimeSlotDetailsForAppointmentModel();
                    TimeSlotDetailsForAppointment.TimeSlot_Category = item[0].TimeSlot_Category;
                    //TimeSlotDetailsForAppointment.TimeSlot_WeekDay = item[0].TimeSlot_WeekDay;
                    lstTimeSlotForAppointment = new List <TimeSlotForAppointmentModel>();
                    foreach (var tm in item)
                    {
                        TimeSlotForAppointment                      = new TimeSlotForAppointmentModel();
                        TimeSlotForAppointment.TimeSlotID           = tm.TimeSlotID;
                        TimeSlotForAppointment.TimeSlot_Description = tm.TimeSlot_Description;
                        //TimeSlotForAppointment.Slot_Start_Time = tm.Slot_Start_Time;
                        //TimeSlotForAppointment.Slot_End_Time = tm.Slot_End_Time;
                        TimeSlotForAppointment.IsTimeSlotAvailable = tm.IsTimeSlotAvailable;
                        lstTimeSlotForAppointment.Add(TimeSlotForAppointment);
                    }
                    TimeSlotDetailsForAppointment.TimeSlot_Appointment = lstTimeSlotForAppointment;
                    appTimeSlot.Add(TimeSlotDetailsForAppointment);
                }
                return(appTimeSlot);
            }
        }