コード例 #1
0
        private async void CheckUser()
        {
            var user = new LoginUserModel()
            {
                Email = Email, Password = Password, RememberMe = true
            };
            var result = await server.LoginUser(user);

            if (result == default(MobileUserServer))
            {
                //peta tou popup oti kanei egine alani
                //edw to login einai unsuccesfull
                try
                {
                    await Shell.Current.Navigation.PushPopupAsync(new InfoPopup("Error", "Something went wrong please enter valid credentials!"));
                }
                catch (NullReferenceException ex)
                {
                    await App.Current.MainPage.Navigation.PushPopupAsync(new InfoPopup("Error", "Something went wrong please enter valid credentials!"));
                }
            }
            else
            {
                //successful login!!! kane kati
                if (IsChecked)
                {
                    var user_temp = new MobileUser()
                    {
                        Email = user.Email, Password = user.Password
                    };
                    try
                    {
                        await database.createUser(user_temp);

                        App.CurrentUserEmail = user_temp.Email;
                    }
                    catch (Exception ex)
                    {
                        await App.Current.MainPage.Navigation.PushPopupAsync(new InfoPopup("Error", "Couldnt save user in the localdb!"));
                    }
                }
                App.CurrentUserEmail = user.Email;
                App.Current.MainPage = new AppShell();
            }
            Console.WriteLine("");
            Console.WriteLine("");
        }