Пример #1
0
 public ActionResult AvailableSchedule(AppointmentScheduleViewModel model, string Command)
 {
     if (Command == "next" && !string.IsNullOrWhiteSpace(model.doctorId))
     {
         return(RedirectToAction("VisitorContactDeatils", new { doctorId = model.doctorId }));
     }
     return(View());
 }
Пример #2
0
        public ActionResult ReScheduling(string doctorId, int bookingId, string userId, string selectedDate = null)
        {
            var model = new AppointmentScheduleViewModel();

            try
            {
                if (!string.IsNullOrWhiteSpace(doctorId) && bookingId > 0 && !string.IsNullOrWhiteSpace(userId))
                {
                    model                     = GetAvailableSchedule(doctorId);
                    model.doctorId            = doctorId;
                    model.AppointmentSchedule = _scheduleService.GetAppointmentScheduleById(bookingId);
                    return(View(model));
                }
            }
            catch
            {
                // ignored
            }
            return(View(model));
        }
        private static AppointmentScheduleViewModel GenrateTimeSlots(string startTime,
                                                                     string endTime, double duration,
                                                                     IList <AppointmentSchedule> bookedSlots)
        {
            try
            {
                var slots = new AppointmentScheduleViewModel();

                var start = DateTime.Parse(startTime);
                var end   = DateTime.Parse(endTime);
                while (true)
                {
                    var dtNext = start.AddMinutes(duration);
                    if (start > end || dtNext > end)
                    {
                        break;
                    }

                    var slot          = start.ToString("hh:mm tt") + " - " + dtNext.ToString("hh:mm tt");
                    var bookingstatus = bookedSlots.Where(s => s.AppointmentTime == slot).FirstOrDefault();

                    var splitSlot = new ScheduleSlotModel
                    {
                        Slot     = slot,
                        IsBooked = bookingstatus == null ? false : true
                    };
                    slots.ScheduleSlotModel.Add(splitSlot);
                    start = dtNext;
                }
                return(slots);
            }
            catch
            {
                return(null);
            }
        }
Пример #4
0
        private static AppointmentScheduleViewModel GenrateTimeSlots(string S1startTime,
                                                                     string E1endTime, string S2startTime,
                                                                     string E2endTime, double duration,
                                                                     IList <AppointmentSchedule> bookedSlots)
        {
            try
            {
                var slots = new AppointmentScheduleViewModel();

                #region Session 1
                if (!string.IsNullOrWhiteSpace(S1startTime) && !string.IsNullOrWhiteSpace(E1endTime))
                {
                    var start = Convert.ToDateTime(S1startTime);
                    var end   = DateTime.Parse(E1endTime);
                    while (true)
                    {
                        bool isBooked = false;
                        var  dtNext   = start.AddMinutes(duration);
                        if (start > end || dtNext > end)
                        {
                            break;
                        }

                        var slot = start.ToString("hh:mm tt") + " - " + dtNext.ToString("hh:mm tt");

                        if (start > DateTime.Now)
                        {
                            var bookingstatus = bookedSlots.Where(s => s.AppointmentTime == slot).FirstOrDefault();
                            if (bookingstatus != null)
                            {
                                isBooked = true;
                            }
                        }
                        else
                        {
                            isBooked = true;
                        }



                        var splitSlot = new ScheduleSlotModel
                        {
                            Slot     = slot,
                            Session  = "Session1",
                            IsBooked = isBooked//bookingstatus == null ? false : true
                        };
                        slots.SessionOneScheduleSlotModel.Add(splitSlot);
                        start = dtNext;
                    }
                }
                #endregion

                #region Session 2
                if (!string.IsNullOrWhiteSpace(S2startTime) && !string.IsNullOrWhiteSpace(E2endTime))
                {
                    var start = DateTime.Parse(S2startTime);
                    var end   = DateTime.Parse(E2endTime);
                    while (true)
                    {
                        bool isBooked = false;
                        var  dtNext   = start.AddMinutes(duration);
                        if (start > end || dtNext > end)
                        {
                            break;
                        }

                        var slot = start.ToString("hh:mm tt") + " - " + dtNext.ToString("hh:mm tt");
                        if (start > DateTime.Now)
                        {
                            var bookingstatus = bookedSlots.Where(s => s.AppointmentTime == slot).FirstOrDefault();
                            if (bookingstatus != null)
                            {
                                isBooked = true;
                            }
                        }
                        else
                        {
                            isBooked = true;
                        }

                        var splitSlot = new ScheduleSlotModel
                        {
                            Slot     = slot,
                            Session  = "Session2",
                            IsBooked = isBooked
                        };
                        slots.SessionTwoScheduleSlotModel.Add(splitSlot);
                        start = dtNext;
                    }
                }
                #endregion

                return(slots);
            }
            catch (Exception ex)
            {
                return(null);
            }
        }