Example #1
0
        public void Execute(object parameter)
        {
            ScheduleSlotModel model = parameter as ScheduleSlotModel;

            сreatingVoucherService.ScheduleSlot = model.Entity;
            navigation.Navigate(new ConfirmChoice());
        }
Example #2
0
        public bool CanExecute(object parameter)
        {
            ScheduleSlotModel model = parameter as ScheduleSlotModel;

            return(model != null && (model.Entity.Doctor.Vouchers == null || !model.Entity.Doctor.Vouchers.Any(voucher =>
                                                                                                               voucher.ScheduleSlot == model.Entity &&
                                                                                                               voucher.State == VoucherState.Opened &&
                                                                                                               voucher.Date.Date == сreatingVoucherService.Date.Date)) &&
                   model.Entity.Doctor
                   .NonWorkingDays?
                   .FirstOrDefault(n => n.Date.Year == сreatingVoucherService.Date.Year &&
                                   n.Date.Month == сreatingVoucherService.Date.Month &&
                                   n.Date.Day == сreatingVoucherService.Date.Day
                                   ) == null);
        }
        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);
            }
        }
        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);
            }
        }