Пример #1
0
        public async void SignUP()
        {
            TriviaWebAPIProxy proxy = TriviaWebAPIProxy.CreateProxy();

            if (string.IsNullOrEmpty(Email) || string.IsNullOrEmpty(Password) || string.IsNullOrEmpty(NickName))
            {
                ErrorMessage = "Please enter email, password and nickname";
            }
            else
            {
                User u = new User
                {
                    Email     = Email,
                    Password  = Password,
                    NickName  = NickName,
                    Questions = new List <AmericanQuestion>()
                };
                bool registered = await proxy.RegisterUser(u);

                if (registered)
                {
                    LoginPage p = new LoginPage();
                    if (NavigateToPageEvent != null)
                    {
                        NavigateToPageEvent(p);
                    }
                }
                else
                {
                    ErrorMessage = "Something went wrong";
                }
            }
        }
Пример #2
0
        private async void Button_Clicked(object sender, EventArgs e)
        {
            //Example of how to use the proxy!
            TriviaWebAPIProxy proxy = TriviaWebAPIProxy.CreateProxy();
            AmericanQuestion  q     = await proxy.GetRandomQuestion();

            //tq.Wait();
            //AmericanQuestion q = tq.Result;
            User user = new User
            {
                Email    = "*****@*****.**",
                NickName = "testNickName",
                Password = "******"
            };
            bool tu = await proxy.RegisterUser(user);

            if (tu)
            {
                AmericanQuestion nq = new AmericanQuestion
                {
                    QText           = "Who is the founder of Testla?",
                    CorrectAnswer   = "Elon Musk",
                    OtherAnswers    = new string[] { "Steve Jobs", "Bill Gates", "George Constanza" },
                    CreatorNickName = "testNickName"
                };
                bool nqt = await proxy.PostNewQuestion(nq);

                if (nqt)
                {
                    bool dt = await proxy.DeleteQuestion(nq);
                }
            }
        }
Пример #3
0
        private async void Register()
        {
            TriviaWebAPIProxy proxy = TriviaWebAPIProxy.CreateProxy();
            User user = new User()
            {
                Email    = Email,
                NickName = Nickname,
                Password = Password
            };
            Task <bool> registerTask = Task.Run(() => proxy.RegisterUser(user));
            await       registerTask;

            if (registerTask.Result)
            {
                ((App)App.Current).User = user;
                if (!popOrPush)
                {
                    PushModal?.Invoke(new QuestioningPage());
                }
                else
                {
                    Pop?.Invoke();
                }
            }
            else
            {
                Error = "Email or NickName Exists";
            }
        }
Пример #4
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";
            }
        }
Пример #5
0
        public async void RegisterAsync()
        {
            TriviaWebAPIProxy proxy = TriviaWebAPIProxy.CreateProxy();
            User uu = new User
            {
                NickName = this.nickname,
                Email    = this.email,
                Password = this.password,
            };
            bool u = await proxy.RegisterUser(uu);

            if (!u)
            {
                Message = "Registration isn't completed successfully";
            }
            else
            {
                App app = (App)App.Current;
                app.CurrentUser = uu;
                await app.MainPage.Navigation.PopModalAsync();
            }
        }