protected async void DeleteRecord(object sender, EventArgs e) { var shouldDelete = await DisplayAlert("Confirm Delete", "Are you sure you want to permanently delete this newcomer?", "Yes", "No"); if (shouldDelete) { if (((SwipeItemView)sender).BindingContext is NewcomerViewModel newcomer) { await _newcomerClient.DeleteNewcomer(newcomer.Id); // refresh view collectionDateEntries.ItemsSource = _dateRecords.Where(x => x.Id != newcomer.Id); // notify user ToastService.DisplaySuccess("Entry successfully removed."); } else { ToastService.DisplayError("An error occurred when deleting the entry."); } } else { ToastService.DisplayInfo("Operation cancelled."); } }
protected async void OpenScanner(object sender, EventArgs e) { var scanner = DependencyService.Get <IQrScanService>(); var result = await scanner.ScanAsync(); if (string.IsNullOrWhiteSpace(result)) { ToastService.DisplayInfo("Scan unsuccessful."); return; } // verify it is an object id if (!ObjectId.TryParse(result, out _)) { ToastService.DisplayError("Invalid scan result. Try again!"); return; } var popup = new AttendanceRegistration(result); await Navigation.ShowPopupAsync(popup); }
protected async void GenerateDateReport(object sender, EventArgs e) { var email = await DisplayPromptAsync("Report", "What email address should the report be sent to?", "Send", "Cancel", "e.g [email protected] (optional)", keyboard : Keyboard.Email); if (email == null) { ToastService.DisplayInfo("Operation cancelled."); return; } if (((SwipeItemView)sender).BindingContext is DateSummaryViewModel summary) { await _attendanceClient.SendAttendanceReport(summary.Date, email); ToastService.DisplaySuccess("Report successfully generated and sent."); } else { ToastService.DisplayError("An error occurred when sending the report."); } }