private async void SaveUserandLinktoErac(Erac erac, EracUser user) { await App.Database.SaveEracUserAsync(user); erac.EracUsers.Add(user); await App.Database.PopulateEracEracQues(erac); }
public async Task <int> DeleteResultAsync(Erac erac) { var eracUsers = GetEracEracUserList(erac.ID).Result; foreach (var eracUser in eracUsers) { await _database.DeleteAsync(eracUser); } return(await _database.DeleteAsync(erac)); }
//Creates a new result in result table or update public Task <int> SaveEracAsync(Erac erac) { if (erac.ID != 0) { return(_database.UpdateAsync(erac)); } else { return(_database.InsertAsync(erac)); } }
private async void OnAddClicked(object sender, EventArgs e) { if (Name.Text == null || NRIC.Text == null || Rank.Text == null) { await DisplayAlert("Missing Information", "Some Fields are not filled in", "Ok"); return; } else { Erac erac = (Erac)BindingContext; EracUser user = new EracUser(); user.Name = Name.Text.ToUpper(); user.Nric = NRIC.Text.ToUpper(); user.Rank = Rank.Text.ToUpper(); SaveUserandLinktoErac(erac, user); await Navigation.PopModalAsync(); } }
async void OnNewRACClicked(object sender, EventArgs e) { bool answer = await DisplayAlert("New RAC", "Create a new RAC?", "Yes", "No"); string resultname = await DisplayPromptAsync("Activity", "", placeholder : "Name of Activity"); if (answer == true && resultname != null) { Erac erac = new Erac(); erac.Name = resultname; erac.DateCreated = DateTime.Now; erac.EracUsers = new List <EracUser>(); await App.Database.SaveEracAsync(erac); await Navigation.PushAsync(new PartyFormPage { BindingContext = erac as Erac }); } else { return; } }
public Task PopulateEracEracQues(Erac erac) { return(_database.UpdateWithChildrenAsync(erac)); }