CreateAccount.xaml.cs 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.Windows;
  7. using System.Windows.Controls;
  8. using System.Windows.Data;
  9. using System.Windows.Documents;
  10. using System.Windows.Input;
  11. using System.Windows.Media;
  12. using System.Windows.Media.Imaging;
  13. using System.Windows.Navigation;
  14. using System.Windows.Shapes;
  15. namespace WinUI.OnboardProcess
  16. {
  17. /// <summary>
  18. /// Interaction logic for CreateAccount.xaml
  19. /// </summary>
  20. public partial class CreateAccount : UserControl, ISwitchable
  21. {
  22. public CreateAccount()
  23. {
  24. InitializeComponent();
  25. }
  26. public void UtilizeState(object state)
  27. {
  28. throw new NotImplementedException();
  29. }
  30. public void CreateAccount_Click(object sender, RoutedEventArgs e)
  31. {
  32. DoCreateAccount();
  33. }
  34. public void BackButton_Click(object sender, RoutedEventArgs e)
  35. {
  36. Switcher.Switch(new RegisterOrLogIn());
  37. }
  38. public async void DoCreateAccount()
  39. {
  40. if (PasswordTextBox1.Password.ToString() != PasswordTextBox2.Password.ToString())
  41. {
  42. ErrorText.Content = "Passwords do not match!";
  43. }
  44. else
  45. {
  46. CentralAPI api = CentralAPI.Instance;
  47. bool accountCreated = await api.Login(EmailAddressTextBox.Text,
  48. PasswordTextBox1.Password.ToString(), true);
  49. if (accountCreated)
  50. {
  51. Switcher.Switch(new CreateOrJoin());
  52. }
  53. else
  54. {
  55. ErrorText.Content = "An error ocurred while creating your account.";
  56. }
  57. }
  58. }
  59. }
  60. }