private async void ButtonLogin_Click(object sender, RoutedEventArgs e) { // Login the user and then load data from the mobile app. if (await AuthenticateAsync()) { // Switch the buttons and load items from the mobile app. // ButtonLogin.Visibility = Visibility.Collapsed; //await InitLocalStoreAsync(); //offline sync support. // await RefreshTodoItems(); User currentUser = null; try { currentUser = await UsersTable.LookupAsync(user.UserId.Substring(4)); var parameters = new MainDashboardParams(currentUser); Frame.Navigate(typeof(MainDashboard), parameters); } catch (Exception) { Frame.Navigate(typeof(UserDeatailsPage), user.UserId.Substring(4)); } } }
private async void Button_Click(object sender, RoutedEventArgs e) { UserTrainingProgram chosenTrainingProgram = null; if ((bool)FirstOption.IsChecked) { chosenTrainingProgram = optionalPrograms[0]; } else if ((bool)SecondOption.IsChecked) { chosenTrainingProgram = optionalPrograms[1]; } else { chosenTrainingProgram = optionalPrograms[2]; } user.CurrentTrainingProgramId = chosenTrainingProgram.Id; try { // Save user details in DB await UserTrainingProgramsTable.InsertAsync(chosenTrainingProgram); await UsersTable.InsertAsync(user); // Show confirmation massage MessageDialog confirmation = new MessageDialog("Thanks, you are now registered!"); await confirmation.ShowAsync(); var parameters = new MainDashboardParams(user); Frame.Navigate(typeof(MainDashboard), parameters); } catch (Exception) { MessageDialog msgDialogError = new MessageDialog("Sorry, we had an error. Please try again."); } }