private void ReviewsBtn_Click(object sender, EventArgs e) { var allReviews = Deserializer <Review> .DeserializeFile(@"..\..\Resources\Reviews.txt"); List <string> users = new List <string> { CurrentUser.ReturnCurrentUserEmail() }; var query = users.GroupJoin(allReviews, user => user, review => review.Author, (user, reviewCollection) => new { UserName = user, Reviews = reviewCollection.Select(review => new { subject = review.Subject.Name, comment = review.Comment, rating = review.Rating }) }); MyReviews myReviewsForm = new MyReviews(); myReviewsForm.usernameLabel.Text = CurrentUser.ReturnCurrentUserEmail(); // Enumerate results. foreach (var person in query) { foreach (var item in person.Reviews) { myReviewsForm.reviewListView.Items.Add(new ListViewItem(new string[] { item.subject, item.comment, item.rating.ToString() })); } } myReviewsForm.Show(); }
private async void ListItemClicked(int position) { Android.Support.V4.App.Fragment fragment = null; switch (position) { case 0: int id = int.Parse(ap.getAccessKey()); string url = "http://housechecker.co.uk/api/export.php"; JsonValue json = await FetchUserAsync(url); string jsonString = json.ToString(); List <Student> listOfLandlords = JsonConvert.DeserializeObject <List <Student> >(jsonString); var user = listOfLandlords.Where(a => a.Id == id).FirstOrDefault(); if (user.Type == "Landlord") { IMenuItem item1 = navigationView.Menu.FindItem(Resource.Id.nav_extra1); item1.SetTitle("Add Property"); IMenuItem item2 = navigationView.Menu.FindItem(Resource.Id.nav_extra2); item2.SetTitle("My Properties"); // If the user type is Landlord, it sets the two extra features to these options } else { IMenuItem item1 = navigationView.Menu.FindItem(Resource.Id.nav_extra1); item1.SetTitle("Favourite Properties"); IMenuItem item2 = navigationView.Menu.FindItem(Resource.Id.nav_extra2); item2.SetTitle("My Reviews"); // If you're a student the options are different } // Gets the list of users and finds the one that matches your ID usernameDisplay = FindViewById <TextView>(Resource.Id.navBarHeader); // Gets the display name for the nav bar if (user.Type == "Landlord") { fragment = LandlordDashboard.NewInstance(); usernameDisplay.Text = user.CompanyName; // Sets the name to company name if you are a landlord } else { fragment = StudentDashboard.NewInstance(); usernameDisplay.Text = user.Name; // And to username if you are a student } break; case 1: fragment = PropertyDetail.NewInstance(); Bundle idBundle = new Bundle(); idBundle.PutString("accomID", "77"); fragment.Arguments = idBundle; // This code calls the new fragment and places it on the screen aka loading a new page break; case 2: fragment = SearchPage.NewInstance(); break; case 3: fragment = Profile.NewInstance(); break; case 4: if (userType == "Landlord") { fragment = AddProperty.NewInstance(); } else { fragment = DisplayFavourites.NewInstance(); } break; case 5: if (userType == "Landlord") { fragment = MyProperties.NewInstance(); } else { fragment = MyReviews.NewInstance(); } break; case 6: id = int.Parse(ap.getAccessKey()); url = "http://housechecker.co.uk/api/export.php"; json = await FetchUserAsync(url); jsonString = json.ToString(); listOfLandlords = JsonConvert.DeserializeObject <List <Student> >(jsonString); user = listOfLandlords.Where(a => a.Id == id).FirstOrDefault(); if (user.Type == "Landlord") { IMenuItem item1 = navigationView.Menu.FindItem(Resource.Id.nav_extra1); item1.SetTitle("Add Property"); IMenuItem item2 = navigationView.Menu.FindItem(Resource.Id.nav_extra2); item2.SetTitle("My Properties"); // If the user type is Landlord, it sets the two extra features to these options } else { IMenuItem item1 = navigationView.Menu.FindItem(Resource.Id.nav_extra1); item1.SetTitle("Favourite Properties"); IMenuItem item2 = navigationView.Menu.FindItem(Resource.Id.nav_extra2); item2.SetTitle("My Reviews"); // If you're a student the options are different } // Gets the list of users and finds the one that matches your ID url = "http://housechecker.co.uk/api/display.php"; json = await FetchUserAsync(url); jsonString = json.ToString(); var addressList = JsonConvert.DeserializeObject <List <Address> >(jsonString); accomID = addressList.Where(a => a.address1 == markerTitle).FirstOrDefault().id; fragment = PropertyDetail.NewInstance(); Bundle bundle = new Bundle(); bundle.PutString("accomID", accomID.ToString()); fragment.Arguments = bundle; // Gets the accomodation that has been clicked on from the map page and then loads it break; } SupportFragmentManager.BeginTransaction() .Replace(Resource.Id.content_frame, fragment) .Commit(); // Commits the transaction }