Exemplo n.º 1
0
        async void SignUp()
        {
            User u = new User
            {
                Email    = Email,
                Password = Password,
                NickName = NickName,
            };
            TriviaWebAPIProxy proxy = TriviaWebAPIProxy.CreateProxy();
            bool b = await proxy.RegisterUser(u);

            if (b)
            {
                Label = "successfully registered! please wait 5 seconds";
                //wait 10 seconds - to learn how
                await Task.Delay(10000);

                User us = await proxy.LoginAsync(Email, Password);

                App.Current.Properties["UserDetail"] = JsonSerializer.Serialize(u);
                Page p = new HomeWhenLogged();

                if (NavigateToPageEvent != null)
                {
                    NavigateToPageEvent(p);
                }
            }
            else
            {
                Label = "The email or nickname is already exsits. Please try another one";
            }
        }
Exemplo n.º 2
0
        private async void Login()
        {
            TriviaWebAPIProxy proxy     = TriviaWebAPIProxy.CreateProxy();
            Task <User>       loginTask = proxy.LoginAsync(Email, Password);
            await             loginTask;

            if (loginTask.Result != null)
            {
                ((App)App.Current).User = loginTask.Result;
                PushModal?.Invoke(new QuestioningPage());
            }
            else
            {
                Error = "Email or NickName Does Not Match";
            }
        }
Exemplo n.º 3
0
        public async void LoginAsync()
        {
            TriviaWebAPIProxy proxy = TriviaWebAPIProxy.CreateProxy();
            User u = await proxy.LoginAsync(Email, Password);

            if (u == null)
            {
                Message = "Email or password incorrect";
            }
            else
            {
                App app = (App)App.Current;
                app.CurrentUser = u;
                await app.MainPage.Navigation.PopModalAsync();
            }
        }
Exemplo n.º 4
0
        async void Log()
        {
            TriviaWebAPIProxy proxy = TriviaWebAPIProxy.CreateProxy();
            User u = await proxy.LoginAsync(Email, Password);

            if (u != null)
            {
                App a = (App)App.Current;
                a.CurrentUser = u;
                try
                {
                    await SecureStorage.SetAsync("email", Email);

                    await SecureStorage.SetAsync("password", Password);
                }
                catch { }

                Application.Current.Properties["IsLoggedIn"] = Boolean.TrueString;


                Page p = null;
                if (NextPage != null)
                {
                    if (NextPage is AddQuestion)
                    {
                        AddQuestionViewModel add             = (AddQuestionViewModel)NextPage.BindingContext;
                        AmericanQuestion     amricanQuestion = await proxy.GetRandomQuestion();

                        add.NextPage = new Game(amricanQuestion, 0);
                        p            = NextPage;
                    }
                }
                else
                {
                    p = new HomeWhenLogged();
                }

                if (NavigateToPageEvent != null)
                {
                    NavigateToPageEvent(p);
                }
            }
            else
            {
                Label = "Email or password is incorrect. Please try again";
            }
        }
Exemplo n.º 5
0
        public async void Login()
        {
            TriviaWebAPIProxy proxy = TriviaWebAPIProxy.CreateProxy();

            if (string.IsNullOrEmpty(Email) || string.IsNullOrEmpty(Password))
            {
                ErrorMessage = "please fill in both fields";
            }
            else
            {
                User user = await proxy.LoginAsync(Email, Password);

                if (user == null)
                {
                    ErrorMessage = "wrong email or password";
                }
                else
                {
                    ((App)Application.Current).currentUser = user;
                    NavigateToPageEvent(new GamePage());
                }
            }
        }