Пример #1
0
 protected void UserLogin()
 {
     if (usernameTxtField.Text == "" || passwordTxtField.Text == "")
     {
         var message = string.Format("Please enter Username/Password");
         var alert = new UIAlertView("Empty input!", message, null, "Ok");
         alert.Show();
     } else {
         var has = _users.Any (s => s.Name == usernameTxtField.Text.ToString ());
         if (has) {
             var user = _users.First(s => s.Name == usernameTxtField.Text.ToString ());
             if (user.Password == passwordTxtField.Text.ToString ()) {
                 var welcomeMessage = string.Format ("Welcome Back " + usernameTxtField.Text + "!");
                 _mainController = new MainViewTabBarController (welcomeMessage);
                 NavigationController.PushViewController (_mainController, true);
                 ReleaseViewController ();
             } else {
                 Times++;
                 if (Times == 4) {
                     var alert1 = new UIAlertView ("Account locked!", "Send email to reset the password!", null, "Cancel", "Reset");
                     alert1.Show ();
                 } else {
                     var alert = new UIAlertView ("Username/Password is incorrect!", "Please, try again!", null, "Ok");
                     alert.Show ();
                     passwordTxtField.Text = "";
                 }
             }
         } else {
             var alert = new UIAlertView("User does not exist!", "Create a new account?", null, "Cancel", "Create");
             alert.Show();
             /* -- alert view call back -- */
             alert.Clicked += (sender, e) => {
                 if (e.ButtonIndex == 1) {
                     if (_registerController == null)
                         _registerController = new RegisterController();
                     NavigationController.PushViewController(_registerController, true);
                 }
             };
         }
     }
 }
Пример #2
0
partial         void registerButtonClick(NSObject sender)
        {
            if (_registerController == null)
                _registerController = new RegisterController();
            NavigationController.PushViewController(_registerController, true);
        }