Esempio n. 1
0
        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);
        }
Esempio n. 2
0
        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);
            }
        }
Esempio n. 3
0
 public MongoVenueInfoObject(VenueInfo info)
 {
     VenueInfo = info;
     Id        = info.Id;
 }
Esempio n. 4
0
 public static void StoreVenueInfo(VenueInfo info)
 {
     _VenueInfoCollection.InsertOne(new MongoVenueInfoObject(info));
 }