Esempio n. 1
0
        private async void SignUpExecute(object obj)
        {
            SignUpStatus = string.Empty;
            if (CheckPassword())
            {
                Recycler recycler = await RecyclerAuth.GetRecycler(Recycler);

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

                    Username        = string.Empty;
                    Password        = string.Empty;
                    FullName        = 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 does not matched with your password";
            }
        }
Esempio n. 2
0
        private async void UpdateAllSub()
        {
            Submission.Material     = Material.MaterialID;
            Submission.MaterialName = Material.MaterialName;
            Submission.Status       = StatusApproved;
            Submission.Points       = Weight * Material.PointsPK;
            Submission.ApprovedDate = DateTime.Today;
            Recycler.TotalPoints   += Submission.Points;
            UpdateRecyclerLevel();
            await RecyclerAuth.UpdateRecycler(Recycler);

            Collector.TotalPoints += Submission.Points;
            await CollectorAuth.UpdateCollector(Collector);

            await SubmissionAuth.UpdateSubmission(Submission);
        }
Esempio n. 3
0
        private async void InitializeFromSubmission()
        {
            Recycler = await RecyclerAuth.GetRecyclerByUsername(Submission.Recycler);

            if (Recycler != null)
            {
                RecyclerUsername = Recycler.Username;
            }
            Collector = await CollectorAuth.GetCollectorByUsername(Submission.Collector);

            Material = await MaterialAuth.GetMaterialById(Submission.Material);

            if (Material != null)
            {
                MaterialName = Material.MaterialName;
            }
        }
Esempio n. 4
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!";
                }
            }
        }
Esempio n. 5
0
        private async void UpdateExecute()
        {
            await RecyclerAuth.UpdateRecycler(Recycler);

            await Application.Current.MainPage.Navigation.PopAsync();
        }