示例#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";
            }
        }
示例#2
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";
            }
        }
示例#3
0
        void GoHome()
        {
            Page p;

            if ((string)App.Current.Properties["IsLoggedIn"] == Boolean.TrueString)
            {
                p = new HomeWhenLogged();
            }
            else
            {
                p = new Home();
            }
            if (NavigateToPageEvent != null)
            {
                NavigateToPageEvent(p);
            }
        }