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 );
            }
        }
 private bool CanExecuteRangeUpdatedCommand ( DateRange dateRange )
 {
     return dateRange != null;
 }
 private void ExecuteRangeUpdatedCommand ( DateRange dateRange )
 {
     _selectedRange = dateRange;
     UpdateSchedule ( false );
 }
        /// <summary>
        /// Navigates to default command.
        /// </summary>
        /// <param name="parameters">The parameters.</param>
        protected override void NavigateToDefaultCommand ( KeyValuePair<string, string>[] parameters )
        {
            var clinicianKey = parameters.GetValue<long> ( "ClinicianKey" );
            var initialDate = parameters.GetValue<DateTime> ( "SelectedDate" );
            _clinicianKey = clinicianKey == 0 ? CurrentUserContext.Staff.Key : clinicianKey;

            SelectedDate = initialDate.Date;
            _selectedRange = new DateRange
                {
                    StartDate = SelectedDate,
                    EndDate = SelectedDate
                };
            UpdateSchedule ( true );

            var requestDispatcher = _asyncRequestDispatcherFactory.CreateAsyncRequestDispatcher ();
            requestDispatcher.AddLookupValuesRequest ( "VisitStatus" );
            IsLoading = true;
            requestDispatcher.ProcessRequests ( HandleGetLookupValuesCompleted, HandleGetLookupValuesException );
        }