private async void SignUpExecute(object obj)
        {
            SignUpStatus = string.Empty;
            if (CheckPassword())
            {
                Collector collector = await CollectorAuth.GetCollector(Collector);

                if (collector == null)
                {
                    Collector.TotalPoints = 0;
                    await CollectorAuth.AddCollector(Collector);

                    Username        = string.Empty;
                    Password        = string.Empty;
                    FullName        = string.Empty;
                    Address         = string.Empty;
                    ConfirmPassword = string.Empty;
                    await Application.Current.MainPage.DisplayAlert("Sign up",
                                                                    "Sign up successful! ", "OK");

                    await Application.Current.MainPage.Navigation.PopAsync();
                }
                else
                {
                    SignUpStatus = "Username already exists! Please choose another username";
                }
            }
            else
            {
                SignUpStatus = "Confirmation password is not matched with your password";
            }
        }
示例#2
0
        private async void SignInExecute(object obj)
        {
            LoginStatus = string.Empty;
            if (CheckUsernameAndPassword())
            {
                User        a    = new User();
                ContentPage view = new ContentPage();
                if (UserType == UserTypeVM.AdminUT)
                {
                    a = await AdminAuth.GetAdmin(User);

                    view = new Views.AdminMainPage();
                }
                else if (UserType == UserTypeVM.RecyclerUT)
                {
                    a = await RecyclerAuth.GetRecycler(User);

                    view = new Views.RecyclerMainPage();
                }
                else
                {
                    a = await CollectorAuth.GetCollector(User);

                    view = new Views.CollectorMainPage();
                }
                if (a != null)
                {
                    if (a.Password == Password)
                    {
                        if (Application.Current.Properties.ContainsKey("loggedIn"))
                        {
                            Application.Current.Properties["loggedIn"] = 1;
                        }
                        else
                        {
                            Application.Current.Properties.Add("loggedIn", 1);
                            await Application.Current.SavePropertiesAsync();
                        }
                        if (a is Recycler)
                        {
                            RecyclerVM.Recycler = (Recycler)a;
                        }
                        else if (a is Collector)
                        {
                            CollectorVM.Collector = (Collector)a;
                        }
                        Username = string.Empty;
                        Password = string.Empty;
                        Application.Current.MainPage = new NavigationPage(view);
                    }
                    else
                    {
                        Application.Current.Properties["loggedIn"] = 0;
                        LoginStatus = "Username or password is wrong!";
                    }
                }
                else
                {
                    LoginStatus = "Username or password not found!";
                }
            }
        }