Exemplo n.º 1
0
        private async void OnConfirm(object sender, EventArgs args)
        {
            string pinCode   = pin.Text;
            int    maxLength = pin.MaxLength;

            if (pinCode.Length != maxLength)
            {
                await DisplayAlert("Alert", $"Pin should have {maxLength} digits", "OK");

                return;
            }

            Service service = new Service();
            User    user    = service.LoginWithPinCode(pinCode);

            if (user != null)
            {
                var mDP = new MasterMenu();
                NavigationPage.SetHasNavigationBar(mDP, false);
                Application.Current.MainPage = new MasterMenu();
                await Navigation.PushAsync(mDP);
            }
            else
            {
                await DisplayAlert("Alert", "Pin code was invalid", "OK");
            }
        }
Exemplo n.º 2
0
        async void OnLogin(object sender, EventArgs args)
        {
            string usernameText = username.Text;
            string passwordText = password.Text;

            if (string.IsNullOrEmpty(usernameText) || string.IsNullOrEmpty(passwordText))
            {
                await DisplayAlert("Alert", "Both a username and password are required to login", "OK");
            }
            else
            {
                try
                {
                    // for testing purposes
                    usernameText = "*****@*****.**";
                    passwordText = "asdf123";

                    Service service = new Service();
                    User    user    = service.Login(usernameText, passwordText);

                    if (user != null)
                    {
                        Application.Current.Properties["UserID"]   = user.ID;
                        Application.Current.Properties["UserName"] = user.Name;

                        if (user.Code != null)
                        {
                            Application.Current.Properties["HasPin"] = true;
                        }

                        var mDP = new MasterMenu();
                        NavigationPage.SetHasNavigationBar(mDP, false);
                        Application.Current.MainPage = new MasterMenu();
                        await Navigation.PushAsync(mDP);
                    }
                    else
                    {
                        await DisplayAlert("Alert", "Username or password was invalid", "OK");
                    }
                }
                catch (Exception e)
                {
                    string message = e.InnerException.ToString();
                }
            }
        }