internal static bool TryGetVenueInfo(string venueId, out VenueInfo info) { var data = _VenueInfoCollection.Find(venueInfo => venueInfo.Id == venueId).FirstOrDefault(); if (data != null) { info = data.VenueInfo; return(true); } info = null; return(false); }
public static VenueInfo GetVenueInformation(string venueId) { if (MongoDatabase.TryGetVenueInfo(venueId, out var info)) { return(info); } var request = WebRequest.CreateHttp(GetFourSquareRequestUrl($"venues/{venueId}")); var content = GetRequestResponseContent(request); if (content == null) { return(null); } try { var data = JsonConvert.DeserializeObject <FoursquareVenueDetailsResponse>(content); var venueInfo = new VenueInfo { Id = data.Response.Venue.Id, Name = data.Response.Venue.Name, PhoneNumber = data.Response.Venue.Contact.FormattedPhone, Address = data.Response.Venue.Location.Address, Description = data.Response.Venue.Description, LikeCount = data.Response.Venue.Likes.Count, PhotoUrls = data.Response.Venue.Photos.Groups.SelectMany(g => g.Items.Select(i => i.Url)).ToList(), Tips = data.Response.Venue.Tips.Groups.SelectMany(g => g.Items.Select(t => new Tip(t))).ToList() }; MongoDatabase.StoreVenueInfo(venueInfo); return(venueInfo); } catch (Exception e) { Console.WriteLine(e); return(null); } }
public MongoVenueInfoObject(VenueInfo info) { VenueInfo = info; Id = info.Id; }
public static void StoreVenueInfo(VenueInfo info) { _VenueInfoCollection.InsertOne(new MongoVenueInfoObject(info)); }