示例#1
0
        private async void SignUpExecute(object obj)
        {
            SignUpStatus = string.Empty;
            if (CheckPassword())
            {
                Recycler recycler = await RecyclerDA.GetRecycler(Recycler);

                if (recycler == null)
                {
                    Recycler.EcoLevel    = EcoLevelOne;
                    Recycler.TotalPoints = 0;
                    await RecyclerDA.AddRecycler(Recycler);

                    Username        = string.Empty;
                    Password        = string.Empty;
                    FullName        = string.Empty;
                    ConfirmPassword = string.Empty;
                    await Application.Current.MainPage.DisplayAlert("Sign Up", "You have successfully created a Recycler account ", "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 == StartViewModel.AdminUserType)
         {
             a = await AdminDA.GetAdmin(User);
         }
         else if (UserType == StartViewModel.RecyclerUserType)
         {
             a = await RecyclerDA.GetRecycler(User);
         }
         else
         {
             a = await CollectorDA.GetCollector(User);
         }
         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)
                 {
                     RecyclerViewModel.Recycler = (Recycler)a;
                     view = new Views.RecyclerMainView();
                 }
                 else if (a is Collector)
                 {
                     CollectorViewModel.Collector = (Collector)a;
                     view = new Views.CollectorMainView();
                 }
                 else
                 {
                     MainViewModel.Admin = a;
                     view = new Views.AdminMainView();
                 }
                 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!";
         }
     }
 }