Guest User

Untitled

a guest
Jul 22nd, 2018
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.79 KB | None | 0 0
  1. public partial class LoginClass : ViewController
  2. {
  3. private static APICore api = new APICore();
  4.  
  5. public LoginClass (IntPtr handle) : base (handle)
  6. {
  7. }
  8.  
  9.  
  10. public void LoginButtonClicked(UIButton sender)
  11. {
  12. LaunchLoginAPIAsync(sender);
  13. }
  14.  
  15.  
  16. private async void LaunchLoginAPIAsync(UIButton sender)
  17. {
  18. string name = Username.Text;
  19. string pass = Password.Text;
  20.  
  21. UserLogin user = await api.Login(name, pass);
  22.  
  23. if (user.isInvalidUsername())
  24. {
  25. //Create Alert
  26. var okAlertController = UIAlertController.Create("Error", " Invalid Username. Please try again with a correct username or register using the link below", UIAlertControllerStyle.Alert);
  27. //Add Action
  28. okAlertController.AddAction(UIAlertAction.Create("OK", UIAlertActionStyle.Default, null));
  29.  
  30. // Present Alert
  31. // PresentViewController(okAlertController, true, null);
  32. }
  33. else if (user.isWrongPassword())
  34. {
  35. //Create Alert
  36. var okAlertController = UIAlertController.Create("Error", "Invalid Password", UIAlertControllerStyle.Alert);
  37. //Add Action
  38. okAlertController.AddAction(UIAlertAction.Create("OK", UIAlertActionStyle.Default, null));
  39. // Present Alert
  40. // PresentViewController(okAlertController, true, null);
  41. }
  42. else if (user.isLoginSuccessful())
  43. {
  44. // Create Alert
  45. var okAlertController = UIAlertController.Create("Logged in!", "Success", UIAlertControllerStyle.Alert);
  46. //Add Action
  47. okAlertController.AddAction(UIAlertAction.Create("OK", UIAlertActionStyle.Default, null));
  48. // PresentViewController(okAlertController, true, null);
  49.  
  50.  
  51. }
  52.  
  53. }
  54. }
Add Comment
Please, Sign In to add comment