Example #1
0
        public UserVM GetUserData(string code)
        {
            if (clientWithToken == null)
            {
                clientWithToken = GetClient(code);
            }
            var user = clientWithToken.GetUser("self");

            return(new UserVM()
            {
                Name = user.firstName + " " + user.lastName,
                PictureUrl = PictureHelper.GetUserPictureUrl(user)
            });
        }
Example #2
0
        public List <WhishListItem> GetRecentVenues(string code)
        {
            List <WhishListItem> recentVenues = new List <WhishListItem>();
            List <WhishListItem> whishlist    = new List <WhishListItem>();
            var whishlistCount = 0;

            if (clientWithToken == null)
            {
                clientWithToken = GetClient(code);
            }

            //get venues already added
            using (var db = new WhishListContext())
            {
                whishlist      = db.WhishList.ToList();
                whishlistCount = db.WhishList.Count();
            }

            //get recent checkins
            string limit  = (int.Parse(ConfigurationManager.AppSettings["limitOfRecentVenues"]) + whishlistCount).ToString();
            var    recent = clientWithToken.GetRecentCheckin(new Dictionary <string, string>
            {
                { "limit", limit }
            });

            foreach (var item in recent)
            {
                //remove those that already are in the whishlist
                if (!whishlist.Any(x => x.VenueId == item.venue.id))
                {
                    var venuePicListAux = clientWithToken.GetVenuePhotos(item.venue.id, null);
                    var pic             = venuePicListAux.Count > 0 ? venuePicListAux.ElementAt(0) : null;
                    var usrPicAux       = PictureHelper.GetUserPictureUrl(item.user);

                    recentVenues.Add(new WhishListItem
                    {
                        UserId           = item.user.id,
                        VenueId          = item.venue.id,
                        VenuePictureUrl  = pic == null ? ConfigurationManager.AppSettings["noImagePath"] : PictureHelper.GetVenuePictureUrl(pic),
                        UserPictureUrl   = usrPicAux,
                        VenueName        = item.venue.name,
                        WhishListItemId  = 0,
                        VenueStreet      = item.venue.location.crossStreet + " - " + item.venue.location.city,
                        VenueDescription = item.venue.description,
                        VenueEmail       = item.venue.contact.email
                    });
                }
            }
            return(recentVenues);
        }
Example #3
0
        public void TestMethod1()
        {
            client = new FourSquare.SharpSquare.Core.SharpSquare(clientId, clientSecret);
            var venues = client.SearchVenues(new Dictionary <string, string>
            {
                { "near", "istanbul" },
                { "query", "yapı kredi" }
            });

            int u = venues.Count;
            var i = client.GetAuthenticateUrl("http://localhost:3000/foursquare/callback");

            var token = client.GetAccessToken(i, "token");


            var t = client.GetRecentCheckin(new Dictionary <string, string> {
                { "limit", "20" }
            });
        }
Example #4
0
        private FourSquare.SharpSquare.Core.SharpSquare GetClient(string code)
        {
            var token   = "";
            var context = HttpContext.Current;

            if (context != null)
            {//get token from cache
                if (context.Cache["token"] == null)
                {
                    client = new FourSquare.SharpSquare.Core.SharpSquare(clientId, clientSecret);
                    token  = client.GetAccessToken(ConfigurationManager.AppSettings["callbackurl"], code);
                    context.Cache["token"] = token;
                }
                else
                {
                    token = context.Cache["token"].ToString();
                }
            }
            return(new FourSquare.SharpSquare.Core.SharpSquare(clientId, clientSecret, token));
        }
Example #5
0
 public TestBase()
 {
     client = new FourSquare.SharpSquare.Core.SharpSquare(clientId, clientSecret);
 }
Example #6
0
 public test()
 {
     client = new FourSquare.SharpSquare.Core.SharpSquare(clientId, clientSecret);
 }
Example #7
0
 public TestBase()
 {
     client = new FourSquare.SharpSquare.Core.SharpSquare(clientId, clientSecret);
 }