private async void OnDeleteAsync() { await CosmosDBService.DeleteDonation(SelectedDonation.Id); if (await _pageService.DisplayAlert("Donation", "Donation deleted.", "Ok", "Cancel")) { await _pageService.PushAsync(new MainTabbedPage()); } }
private async void OnCancelAsync() { SelectedDonation.AcceptedBy = null; await CosmosDBService.UpdateDonation(SelectedDonation); if (await _pageService.DisplayAlert("Donation", "Cancelled.", "Ok", "Cancel")) { await _pageService.PushAsync(new MainTabbedPage()); } }
private async void OnAcceptAsync() { SelectedDonation.AcceptedBy = AppSettings.GetValueOrDefault("UserId", ""); await CosmosDBService.UpdateDonation(SelectedDonation); if (await _pageService.DisplayAlert("Donation", "Accepted donation.", "Ok", "Cancel")) { await _pageService.PushAsync(new MainTabbedPage()); } }
private async void OnSubmit() { NewDonation.CreatedAt = DateTime.Now; NewDonation.BusinessName = AppSettings.GetValueOrDefault("Name", ""); NewDonation.CreatedBy = AppSettings.GetValueOrDefault("UserId", ""); NewDonation.Address.Street = AppSettings.GetValueOrDefault("Street", ""); NewDonation.Address.City = AppSettings.GetValueOrDefault("City", ""); NewDonation.Address.Postcode = AppSettings.GetValueOrDefault("Postcode", ""); await CosmosDBService.CreateDonation(NewDonation); if (await _pageService.DisplayAlert("Success", "Donation created.", "OK", "Cancel")) { await _pageService.PushAsync(new MainTabbedPage()); } }
async Task GetDonations() { IsRefreshing = true; if (_type == "org_available") { DonationList = await CosmosDBService.GetDonationsAsync(AppSettings.GetValueOrDefault("City", "")); } if (_type == "org_accepted") { DonationList = await CosmosDBService.GetAcceptedDonations(AppSettings.GetValueOrDefault("UserId", "")); } if (_type == "business") { DonationList = await CosmosDBService.GetUsersDonations(AppSettings.GetValueOrDefault("UserId", "")); } IsRefreshing = false; }
private async Task Login(string uname, string pw) { User loginUser = await CosmosDBService.GetByUsernameAsync(uname); if (loginUser == null) { await _pageService.DisplayAlert("Error", "Username not found", "OK", "Cancel"); } else if (!Hasher.Verify(pw, loginUser.Password)) { await _pageService.DisplayAlert("Error", "Wrong password", "OK", "Cancel"); } else { UpdateAppSettings(loginUser); await _pageService.PushAsync(new MainTabbedPage()); } }
private async void OnSubmit() { if (Validate()) { newUser.Username = Username.Value; newUser.Name = Name.Value; newUser.Address = new Address { Street = Street.Value, City = City.Value, Postcode = Postcode.Value }; newUser.Email = Email.Value; newUser.PhoneNo = PhoneNo.Value; newUser.Password = Hasher.Hash(Password.Value); newUser.Type = Type.Value; await CosmosDBService.CreateUser(newUser); if (await _pageService.DisplayAlert("Registered", "Successfully registered.", "OK", "Cancel")) { await _pageService.PushAsync(new LoginView()); } } }
async Task GetUserAsync() { AcceptedBy = await CosmosDBService.GetByIdAsync(SelectedDonation.AcceptedBy); }