1- using Microsoft . Maui ;
1+ using Microsoft . Extensions . Logging . Abstractions ;
2+ using Microsoft . Maui ;
23using Microsoft . Maui . Controls ;
34using System ;
45using System . Collections . Generic ;
@@ -14,8 +15,10 @@ public partial class AppointmentsPage : ContentPage
1415 public AppointmentsPage ( )
1516 {
1617 InitializeComponent ( ) ;
17- var upcomingEvents = ( this . BindingContext as SchedulerViewModel ) . Events . Where ( x => ( x as Appointment ) . From > DateTime . Now ) . ToList ( ) ;
18- this . Scheduler . AppointmentsSource = upcomingEvents ;
18+ var upcomingEvents = ( this . BindingContext as SchedulerViewModel ) ? . Events ? . Where ( x => ( x as Appointment ) . From > DateTime . Now ) . ToList ( ) ;
19+ if ( upcomingEvents != null )
20+ this . Scheduler . AppointmentsSource = upcomingEvents ;
21+
1922 this . Scheduler . MinimumDateTime = DateTime . Now ;
2023 }
2124
@@ -28,7 +31,11 @@ private void Button_Clicked(object sender, EventArgs e)
2831
2932 if ( button != null && button . Text == "Upcoming appointments" )
3033 {
31- var upcomingEvents = ( this . BindingContext as SchedulerViewModel ) . Events . Where ( x=> ( x as Appointment ) . From > DateTime . Now ) . ToList ( ) ;
34+ var upcomingEvents = ( this . BindingContext as SchedulerViewModel ) ? . Events ? . Where ( x => ( x as Appointment ) . From > DateTime . Now ) . ToList ( ) ;
35+ if ( upcomingEvents == null )
36+ {
37+ return ;
38+ }
3239 if ( upcomingAppointmentBorder != null )
3340 {
3441 upcomingAppointmentBorder . Color = Color . FromArgb ( "#512BD4" ) ;
@@ -44,7 +51,12 @@ private void Button_Clicked(object sender, EventArgs e)
4451 }
4552 else if ( button != null && button . Text == "Past appointments" )
4653 {
47- var pastAppointments = ( this . BindingContext as SchedulerViewModel ) . Events . Where ( x => ( x as Appointment ) . From < DateTime . Now ) . ToList ( ) ;
54+ var pastAppointments = ( this . BindingContext as SchedulerViewModel ) ? . Events ? . Where ( x => ( x as Appointment ) . From < DateTime . Now ) . ToList ( ) ;
55+
56+ if ( pastAppointments == null )
57+ {
58+ return ;
59+ }
4860
4961 if ( pastAppointmentBordeer != null )
5062 {
0 commit comments