Ejemplo n.º 1
0
        private void UpdateSchedule(bool forceRefresh)
        {
            if (_clinicianKey.HasValue)
            {
                if (ClinicianSchedule != null && !forceRefresh)
                {
                    if (_selectedRange.StartDate.Date == _selectedRange.EndDate.Date)
                    {
                        ChangeDate(_selectedRange.StartDate);
                    }
                    else if (_selectedRange.StartDate.Date > SelectedDate ||
                             _selectedRange.EndDate.Date < SelectedDate)
                    {
                        _selectedRange.StartDate = SelectedDate.GetFirstDayOfWeek();
                        _selectedRange.EndDate   = _selectedRange.StartDate.AddDays(6);
                    }
                }
                else if (forceRefresh && _selectedRange.StartDate.Date == _selectedRange.EndDate.Date)
                {
                    _selectedRange = new DateRange
                    {
                        StartDate = SelectedDate,
                        EndDate   = SelectedDate
                    };
                }

                var requestDispatcher = _asyncRequestDispatcherFactory.CreateAsyncRequestDispatcher();
                requestDispatcher.Add(
                    new GetClinicianScheduleByClinicianKeyAndDateRangeRequest
                {
                    ClinicianKey      = _clinicianKey.Value,
                    StartDate         = _selectedRange.StartDate,
                    EndDate           = _selectedRange.EndDate,
                    SlotSizeInMinutes = TimeSlotSizeInMinutes,
                    BeginTime         = DailyScheduleStartTime,
                    EndTime           = DailyScheduleEndTime
                });
                IsLoading = true;
                requestDispatcher.ProcessRequests(
                    HandleGetClinicianScheduleByClinicianKeyAndDateRangeCompleted, HandleGetClinicianScheduleByClinicianKeyAndDateRangeException);
            }
        }