public HouseMapAnnotation (CLLocationCoordinate2D coordinate, string title, House house, string rank) { this.coordinate = coordinate; this.title = title; this.House = house; this.subtitle = string.Format ("({0}) Likes",house.Likes); this.Rank = rank; }
public string GetRankForHouse(House house) { var grouping = houses.GroupBy (x => x.Likes).ToList(); var rank = 1; foreach (var group in grouping.OrderByDescending(x=>x.Key)) { if (group.Any (x=>x.ObjectId == house.ObjectId)) return group.Count() > 1 ? string.Format("T{0}",rank.ToString()) : rank.ToString (); rank++; } return rank.ToString(); }
private async void FetchImageAsync(MKAnnotationView annotationView, House house) { try { if (house.Thumbnail == null) return; UIImage thumbnail; //Check Cache First var houseImageCache = await parent.imageCacheRepo.GetHouseImagesFor(house.ObjectId); if (houseImageCache == null) { //If Not in Cache set cache; var byteArray = await new HttpClient ().GetByteArrayAsync (house.Thumbnail.Url); parent.imageCacheRepo.SaveHouseImages(new HouseImages(){ObjectId = house.ObjectId, Thumbnail= byteArray}); thumbnail = UIImage.LoadFromData (NSData.FromArray (byteArray)); } else { if (houseImageCache.Thumbnail != null) { thumbnail = UIImage.LoadFromData (NSData.FromArray (houseImageCache.Thumbnail)); } else { var byteArray = await new HttpClient ().GetByteArrayAsync (house.Thumbnail.Url); houseImageCache.Thumbnail = byteArray; await parent.imageCacheRepo.UpdateHouseImages(houseImageCache); thumbnail = UIImage.LoadFromData (NSData.FromArray (byteArray)); } } annotationView.LeftCalloutAccessoryView = new UIImageView(thumbnail); } catch (Exception e) { Console.WriteLine ("Error Retrieving Image. {0}", e.Message); } }