async Task displayUserName() { var usersTable = await tableManager.GetUserAsync(); var user = usersTable.Where(u => String.Equals(sid, u.UserId)).ElementAt(0); Name.Text = String.Format("{0} {1}", user.FirstName, user.LastName); }
public async void OnSelected(object sender, SelectedItemChangedEventArgs e) { var item = e.SelectedItem as Boardgames; var userTable = await tableManager.GetUserAsync(); await Navigation.PushModalAsync(new ItemViewPage(item, userTable.Where(u => string.Equals(u.UserId, item.Owner)).ElementAt(0))); await RefreshItems(false, syncItems : false); }
// Creating JSON object to represent the request made, and then adding it to database table 'requests' in backend public async void OnBorrow(object sender, EventArgs e) { var usersTable = await tableManager.GetUserAsync(); var lenders = usersTable.Where(a => a.UserId == owner); if (lenders.Count() > 0) { User lender = lenders.ElementAt(0); string borrower = await App.Authenticator.GetUserId(); string startDateString = String.Format("{0:dd/MM/yyyy}", startDate.Date); string endDateString = String.Format("{0:dd/MM/yyyy}", endDate.Date); var request = new Request { Borrower = borrower, Lender = owner, ItemId = id, StartDate = startDateString, EndDate = endDateString, Accepted = "Pending" }; await AddItem(request); string msg = "Request sent to " + lender.FirstName + " " + lender.LastName + " to borrow " + gameName.Text + " from " + startDateString + " to " + endDateString; await DisplayAlert("Success", msg, "Okay"); await Navigation.PopModalAsync(false); } }
public async Task <List <User> > createTrustNetwork() { string sid = curVouchee.UserId; 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); }
async void updateDetails(bool isItem) { string name; if (isItem) { var itemsTable = await manager.GetBoardgamesAsync(); name = itemsTable.Where(item => string.Equals(reviewedEntityID, item.Id)).Select(col => col.Name).ElementAt(0); } else { var usersTable = await manager.GetUserAsync(); User user = usersTable.Where(u => string.Equals(reviewedEntityID, u.UserId)).ElementAt(0); name = String.Format("{0} {1}", user.FirstName, user.LastName); } pageTitle.Text = "Reviews for " + name; overallRating.Value = await getOverallRating(); }
private async Task RefreshItems(bool showActivityIndicator, bool syncItems) { string sid = await App.Authenticator.GetUserId(); var reqs = await tableManager.GetRequestAsync(syncItems); var games = await tableManager.GetBoardgamesAsync(syncItems); var users = await tableManager.GetUserAsync(syncItems); var lenderAcceptedRequests = reqs.Where(r => (String.Equals(r.Lender, sid)) && (r.Accepted.Equals("True"))); var borrowAcceptedRequests = reqs.Where(r => (String.Equals(r.Borrower, sid)) && (r.Accepted.Equals("True"))); List <RequestMessage> borrows = new List <RequestMessage>(); List <RequestMessage> lends = new List <RequestMessage>(); string requestType = "Lend Request"; string requestStatus = "Accepted"; string col = "#00cc00"; string seenUnseenCol = "#E0E0E0"; foreach (Request r in lenderAcceptedRequests) { User borrowingUser = users.Where(user => String.Equals(r.Borrower, user.UserId)).ElementAt(0); Boardgames requestedItem = games.Where(game => String.Equals(r.ItemId, game.Id)).ElementAt(0); string notifView = String.Format("{0}", requestedItem.Name); string notifViewDetail = String.Format(" "); if (borrowingUser.UserId == Receiver.UserId) { lends.Add(new RequestMessage(requestedItem, borrowingUser, requestType, requestStatus, r.UpdatedAt, notifView, notifViewDetail, col, seenUnseenCol, r)); } } requestType = "Borrow Request"; requestStatus = "Accepted"; foreach (Request r in borrowAcceptedRequests) { User lendingUser = users.Where(user => String.Equals(r.Lender, user.UserId)).ElementAt(0); Boardgames requestedItem = games.Where(game => String.Equals(r.ItemId, game.Id)).ElementAt(0); string notifView = String.Format("{0}", requestedItem.Name); string notifViewDetail = String.Format(" "); if (lendingUser.UserId == Receiver.UserId) { borrows.Add(new RequestMessage(requestedItem, lendingUser, requestType, requestStatus, r.UpdatedAt, notifView, notifViewDetail, col, seenUnseenCol, r)); } } borrowList.ItemsSource = borrows; lendList.ItemsSource = lends; }
public async Task <bool> hasRegistered() { var usersTable = await manager.GetUserAsync(); var userId = await App.Authenticator.GetUserId(); Debug.WriteLine("UserId:{0}", userId); var results = usersTable.Where(a => a.UserId == userId); Debug.WriteLine("resultsCount: {0}", results.Count()); return(results.Count() != 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); }
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); }
private async Task RefreshItems(bool showActivityIndicator, bool syncItems) { var reviews = await manager.GetRatingsAsync(); var entityReviews = reviews.Where(r => string.Equals(r.RatedID, item.Id)); var usersTable = await manager.GetUserAsync(); foreach (Ratings rating in entityReviews) { User reviewingUser = usersTable.Where(u => string.Equals(rating.ReviewerID, u.UserId)).ElementAt(0); rating.Reviewer = String.Format("{0} {1}", reviewingUser.FirstName, reviewingUser.LastName); } var size = entityReviews.Count(); allReviews.ItemsSource = entityReviews; allReviews.HeightRequest = size * 140; }