public async Task SaveVouchAsync(Vouch item) { if (item.Id == null) { await vouchTable.InsertAsync(item); } else { await vouchTable.UpdateAsync(item); } }
private async void displayVouchDetails() { VouchMessage.Text = await trustNetworkToString(await createTrustNetwork()); var vouch = new Vouch(); vouch.Voucher = await App.Authenticator.GetUserId(); vouch.Vouchee = profOwner.UserId; var vouchTable = await tableManager.GetVouchAsync(); bool alreadyVouched = vouchTable.Where(entry => String.Equals(vouch.Vouchee, entry.Vouchee) && String.Equals(vouch.Voucher, entry.Voucher)).Count() > 0; if (alreadyVouched) { vouchButton.Text = "Unvouch"; } else { vouchButton.Text = "Vouch"; } }
public async void ClickVouch(object sender, EventArgs e) { var vouch = new Vouch(); vouch.Voucher = await App.Authenticator.GetUserId(); vouch.Vouchee = profOwner.UserId; var vouchTable = await tableManager.GetVouchAsync(); var userTable = await tableManager.GetUserAsync(); User owner = userTable.Where(u => String.Equals(u.UserId, profOwner.UserId)).ElementAt(0); bool alreadyVouched = vouchTable.Where(entry => String.Equals(vouch.Vouchee, entry.Vouchee) && String.Equals(vouch.Voucher, entry.Voucher)).Count() > 0; if (!alreadyVouched) { await tableManager.SaveVouchAsync(vouch); vouchButton.Text = "Unvouch"; await DisplayAlert("Success", String.Format("You have now vouched for {0}!", owner.FirstName), "OK"); } else { var vouched = vouchTable.Where(entry => String.Equals(vouch.Vouchee, entry.Vouchee) && String.Equals(vouch.Voucher, entry.Voucher)).ElementAt(0); await tableManager.DeleteVouchAsync(vouched); vouchButton.Text = "Vouch"; await DisplayAlert("Success", String.Format("You have now Unvouched {0}!", owner.FirstName), "OK"); } displayVouchDetails(); }
public async Task DeleteVouchAsync(Vouch item) { await vouchTable.DeleteAsync(item); }