public void onSaveClick() { if (Todo == null || mContentPage == null) { return; } Todo.From = DateFrom.Add(TimeFrom); Todo.To = DateTo.Add(TimeTo); if (Todo.From.CompareTo(Todo.To) > 0 || String.IsNullOrEmpty(Todo.Title)) { mContentPage.DisplayAlert("Warning", "1.Please enter \"Title\"\n" + "2.Time To > Date From", "OK"); return; } App.Database.SaveItemAsync(Todo); if (Todo.IsDone == true) { DependencyService.Get <IAlarm>().CancelAlarm(Todo); } else { DependencyService.Get <IAlarm>().SetAlarm(Todo); } mContentPage.Navigation.PopAsync(); }