예제 #1
0
        public async Task <List <User> > createTrustNetwork()
        {
            string sid = await App.Authenticator.GetUserId();

            var vouchTable = await tableManager.GetVouchAsync();

            var userTable = await tableManager.GetUserAsync();

            var currentUserVouchList = vouchTable.Where(owner => String.Equals(sid, owner.Voucher));

            List <User> vouchList = new List <User>();

            foreach (Vouch v in currentUserVouchList)
            {
                User vouchee = userTable.Where(u => String.Equals(u.UserId, v.Vouchee)).ElementAt(0);
                vouchList.Add(vouchee);
            }

            return(vouchList);
        }
예제 #2
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();
        }
예제 #3
0
        private async void DisplayList()
        {
            var sid = await App.Authenticator.GetUserId();

            var vouchTable = await tableManager.GetVouchAsync();

            var userTable = await tableManager.GetUserAsync();

            var currentUserVouchList = vouchTable.Where(owner => String.Equals(sid, owner.Vouchee));

            List <User> vouchNetwork = new List <User>();

            foreach (Vouch v in currentUserVouchList)
            {
                User voucher = userTable.Where(u => String.Equals(u.UserId, v.Voucher)).ElementAt(0);
                vouchNetwork.Add(voucher);
            }



            voucheeList.ItemsSource = await createUserListView(vouchNetwork);
        }
예제 #4
0
        public async Task <List <User> > createTrustNetwork()
        {
            string sid = await App.Authenticator.GetUserId();

            var vouchTable = await tableManager.GetVouchAsync();

            var userTable = await tableManager.GetUserAsync();

            var currentUserVouchList = vouchTable.Where(owner => String.Equals(sid, owner.Voucher));

            List <User> vouchNetwork = new List <User>();

            foreach (Vouch v in currentUserVouchList)
            {
                var nestedVouchList = vouchTable.Where(vouch => String.Equals(v.Vouchee, vouch.Voucher));


                if (String.Equals(v.Vouchee, profOwner.UserId))
                {
                    User voucher = userTable.Where(u => String.Equals(u.UserId, v.Voucher)).ElementAt(0);
                    vouchNetwork.Add(voucher);
                }

                else
                {
                    foreach (Vouch z in nestedVouchList)
                    {
                        if (String.Equals(z.Vouchee, profOwner.UserId))
                        {
                            User voucher = userTable.Where(u => String.Equals(u.UserId, z.Voucher)).ElementAt(0);
                            vouchNetwork.Add(voucher);
                        }
                    }
                }
            }
            return(vouchNetwork);
        }