@@ -21,50 +21,72 @@ public CalendarsPage(ICalendarStore calendarStore)
2121
2222 async void LoadCalendars_Clicked ( object sender , EventArgs e )
2323 {
24- await LoadCalendars ( ) ;
24+ try
25+ {
26+ await LoadCalendars ( ) ;
27+ }
28+ catch ( Exception ex )
29+ {
30+ await DisplayAlert ( "Error" , ex . Message , "OK" ) ;
31+ }
32+
2533 }
2634
2735 async void CreateCalendar_Clicked ( object sender , EventArgs e )
2836 {
29- var createResult = await DisplayPromptAsync ( "Create Calendar" ,
30- "What do you want to name the calendar?" ) ;
31-
32- if ( string . IsNullOrWhiteSpace ( createResult ) )
37+ try
3338 {
34- return ;
35- }
39+ var createResult = await DisplayPromptAsync ( "Create Calendar" ,
40+ "What do you want to name the calendar?" ) ;
41+
42+ if ( string . IsNullOrWhiteSpace ( createResult ) )
43+ {
44+ return ;
45+ }
3646
37- await calendarStore . CreateCalendar ( createResult ) ;
47+ await calendarStore . CreateCalendar ( createResult ) ;
3848
39- await LoadCalendars ( ) ;
49+ await LoadCalendars ( ) ;
4050
41- await DisplayAlert ( "Calendar Created" ,
42- $ "Calendar \" { createResult } \" created successfully.", "OK" ) ;
51+ await DisplayAlert ( "Calendar Created" ,
52+ $ "Calendar \" { createResult } \" created successfully.", "OK" ) ;
53+ }
54+ catch ( Exception ex )
55+ {
56+ await DisplayAlert ( "Error" , ex . Message , "OK" ) ;
57+ }
4358 }
4459
4560 async void Update_Clicked ( object sender , EventArgs e )
4661 {
47- if ( ( sender as BindableObject ) ? .
48- BindingContext is not Calendar calendarToUpdate )
62+ try
4963 {
50- await DisplayAlert ( "Error" , "Could not determine calendar to update." , "OK" ) ;
51- return ;
52- }
64+ if ( ( sender as BindableObject ) ? .
65+ BindingContext is not Calendar calendarToUpdate )
66+ {
67+ await DisplayAlert ( "Error" , "Could not determine calendar to update." , "OK" ) ;
68+ return ;
69+ }
5370
54- var updateResult = await DisplayPromptAsync ( "Update Calendar" ,
55- "Enter the updated calendar name:" , placeholder : calendarToUpdate . Name ) ;
71+ var updateResult = await DisplayPromptAsync ( "Update Calendar" ,
72+ "Enter the updated calendar name:" , placeholder : calendarToUpdate . Name ) ;
5673
57- if ( string . IsNullOrWhiteSpace ( updateResult ) )
58- {
59- return ;
60- }
74+ if ( string . IsNullOrWhiteSpace ( updateResult ) )
75+ {
76+ return ;
77+ }
6178
62- await calendarStore . UpdateCalendar ( calendarToUpdate . Id , updateResult ) ;
79+ await calendarStore . UpdateCalendar ( calendarToUpdate . Id , updateResult ) ;
6380
64- await LoadCalendars ( ) ;
81+ await LoadCalendars ( ) ;
6582
66- await DisplayAlert ( "Calendar Updated" ,
67- $ "Calendar \" { updateResult } \" updated successfully.", "OK" ) ;
83+ await DisplayAlert ( "Calendar Updated" ,
84+ $ "Calendar \" { updateResult } \" updated successfully.", "OK" ) ;
85+ }
86+ catch ( Exception ex )
87+ {
88+ await DisplayAlert ( "Error" , ex . Message , "OK" ) ;
89+ }
6890 }
6991
7092 async void Delete_Clicked ( object sender , EventArgs e )
0 commit comments