private async void OpenCollectorMaterialExecute(Material material) { Collector collector = CollectorVM.Collector; if (collector.MaterialCollection == null) { collector.MaterialCollection = new List <string>(); } collector.MaterialCollection.Add(material.MaterialID); await CollectorAuth.UpdateCollector(collector); if (material.CollectorList == null) { material.CollectorList = new List <string>(); } material.CollectorList.Add(collector.Username); await MaterialAuth.UpdateMaterial(material); CollectorMaterialList.Remove(material); await Application.Current.MainPage.DisplayAlert("Materials", "Material " + material.MaterialName + " is successfully added into collection.", "OK"); //await Application.Current.MainPage.Navigation.PopAsync(); }
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"; } }
//to update collector profile private async void UpdateCollectorExecute() { await CollectorAuth.UpdateCollector(Collector); await Application.Current.MainPage.DisplayAlert("Profile update", "Profile successfully updated ", "OK"); await Application.Current.MainPage.Navigation.PopAsync(); }
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); }
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; } }
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!"; } } }
protected async override void OnAppearing() { base.OnAppearing(); collectorListView.ItemsSource = await CollectorAuth.GetCollectorsByUsername(SubmissionVM.Material.CollectorList); }
private async void GetCollectorList() { CollectorList = await CollectorAuth.GetCollectorsByUsername(Material.CollectorList); }