Exemplo n.º 1
0
        async void LoginAction(object sender, EventArgs e)
        {
            if (!string.IsNullOrWhiteSpace(usernameText.Text) && !string.IsNullOrWhiteSpace(passwordText.Text))
            {
                UserService userService = UserService.Instance;
                await userService.LoginAction(usernameText.Text, passwordText.Text);

                if (userService.GetUser() == null)
                {
                    await this.DisplayAlert("Erreur", "Utillisateur ou mot de passe invalide", "OK");
                }
                else
                {
                    var user = userService.GetUser();
                    //Insert or update the user in the database and all of his child object a.k.a HistoricWine objects
                    SQLiteService.Insert_UpdateObject <UserModel> (user);
                    await Navigation.PushModalAsync(new MainPage());

                    System.Diagnostics.Debug.WriteLine(userService.GetUser().historicWines[0].id);
                }
            }
            else
            {
                //InputEffectExtensions.InputChangeBorderColor(usernameTextInput, "#e4655f", 0.5f);
                //InputEffectExtensions.InputChangeBorderColor(passwordTextIput, "#e4655f", 0.5f);
            }
        }
Exemplo n.º 2
0
        public App()
        {
            // The root page of your application
            InitializeComponent();
            var users = SQLiteService.FetchObject <UserModel> (u => u.isCurrentUser == true);

            if (users.Count > 0)
            {
                UserService.Instance.SetUser(users [0]);
                MainPage = new Wineot.MainPage();
            }
            else
            {
                MainPage = new Wineot.LoginPage();
            }
        }