LoadPlaces

async public void LoadPlaces() { var placesResponse = await ApiService.GetPlaces(); if (placesResponse.HttpResponse.StatusCode == System.Net.HttpStatusCode.OK) { var picturesResponse = await ApiService.GetPictures(); if (picturesResponse.HttpResponse.StatusCode == System.Net.HttpStatusCode.OK) { Places = new ObservableCollection<PlaceViewModel>(); foreach (var place in placesResponse.Response) { var placeViewModel = new PlaceViewModel { Description = place.Description, Id = place.Id, Likes = place.Likes, Location = place.Location, Name = place.Name, Thumbnail = place.Thumbnail, Pictures = new ObservableCollection<PictureViewModel>() }; var pictures = picturesResponse.Response.Where(x => x.PlaceId == place.Id); if (pictures != null && pictures.Count() > 0) { foreach (var picture in pictures) { placeViewModel.Pictures.Add(new PictureViewModel { Id = picture.Id, Uri = picture.Uri }); } } Places.Add(placeViewModel); } } else { //Error } } else { //Error } }

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.