Example #1
0
 public async Task SaveVouchAsync(Vouch item)
 {
     if (item.Id == null)
     {
         await vouchTable.InsertAsync(item);
     }
     else
     {
         await vouchTable.UpdateAsync(item);
     }
 }
Example #2
0
        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";
            }
        }
Example #3
0
        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();
        }
Example #4
0
 public async Task DeleteVouchAsync(Vouch item)
 {
     await vouchTable.DeleteAsync(item);
 }