Inheritance: FourSquareEntity
 private Place ConvertPlace(Venue venue)
 {
     Place newPlace = new Place()
     {
         ExternalId = venue.id,
         Name = venue.name,
         Description = venue.description,
         Latitude = venue.location.lat.ToString(),
         Longitude = venue.location.lng.ToString(),
         SourceType = SourceType.FourSquare
     };
     _placeService.InsertIfNotExist(newPlace);
     return newPlace;
 }
Exemplo n.º 2
0
        public ActionResult venues()
        {
            SharpSquare sharpSquare = new SharpSquare(clientId, clientSecret);
            BancoContext db = new BancoContext();
            int lastid = 0;
            Dictionary<string, string> parametros = new Dictionary<string, string>();

            List<Banco.Models.Venue> lisVenue = db.Venues.Where(w => w.updated.Year < 1950).ToList();

            foreach (Banco.Models.Venue ven in lisVenue)
            {
                try
                {
                    FourSquare.SharpSquare.Entities.Venue v = new FourSquare.SharpSquare.Entities.Venue();
                    lastid = ven.Id;
                    v = sharpSquare.GetVenue(ven.SquareId);
                    ven.checkincount = (int)v.stats.checkinsCount;
                    ven.tipcount = (int)v.stats.tipCount;
                    ven.rate = v.rating;
                    if (v.price != null)
                        ven.tier = v.price.tier;
                    ven.likes = (int)v.likes.count;
                    ven.updated = DateTime.Now;
                    db.SaveChanges();
                }
                catch (Exception e)
                {
                    if (e.Message == "O servidor remoto retornou um erro: (403) Proibido.")
                    {
                        ViewBag.Message = e.Message;
                        break;
                    }
                }
            }
            return View();
        }