Beispiel #1
0
        public List <Venue> SearchVenues(VenueSearchCategory input)
        {
            List <Venue> result = new List <Venue>();

            FoursquareBusiness.Service srv        = new FoursquareBusiness.Service(clientId, clientSecret);
            List <Parameter>           parameters = new List <Parameter>();

            if (!string.IsNullOrEmpty(input.category))
            {
                var    categoryList = srv.GetVenueCategories();
                string categoryId   = "";
                foreach (var item in categoryList)
                {
                    foreach (var detailedItem in item.categories)
                    {
                        if (detailedItem.name.Contains(input.category))
                        {
                            categoryId += item.id + ",";
                        }
                    }
                }
                parameters.Add(new Parameter
                {
                    KeyName  = "categoryId",
                    KeyValue = categoryId.Remove(categoryId.Length - 1)
                });
            }

            if (!string.IsNullOrEmpty(input.location.near))
            {
                parameters.Add(new Parameter
                {
                    KeyName  = "near",
                    KeyValue = input.location.near
                });
            }
            else
            {
                if (!string.IsNullOrEmpty(input.location.latitude) && !string.IsNullOrEmpty(input.location.longtitude))
                {
                    parameters.Add(new Parameter
                    {
                        KeyName  = "ll",
                        KeyValue = input.location.latitude.Replace(',', '.') + "," + input.location.longtitude.Replace(',', '.')
                    });
                }
            }
            result = srv.SearchVenues(parameters);
            return(result);
        }
Beispiel #2
0
        public List <Tip> SearchTip(TipSearch input)
        {
            List <Parameter> parameters = new List <Parameter>();

            if (!string.IsNullOrEmpty(input.location.near))
            {
                parameters.Add(new Parameter
                {
                    KeyName  = "near",
                    KeyValue = input.location.near
                });
            }
            else
            {
                if (!string.IsNullOrEmpty(input.location.latitude) && !string.IsNullOrEmpty(input.location.longtitude))
                {
                    parameters.Add(new Parameter
                    {
                        KeyName  = "ll",
                        KeyValue = input.location.latitude.Replace(',', '.') + "," + input.location.longtitude.Replace(',', '.')
                    });
                }
            }
            if (!string.IsNullOrEmpty(input.name))
            {
                parameters.Add(new Parameter
                {
                    KeyName  = "query",
                    KeyValue = input.name
                });
            }
            FoursquareBusiness.Service srv = new FoursquareBusiness.Service(clientId, clientSecret);
            var venueList = srv.SearchVenues(parameters);
            //var venueDetail = srv.GetVenue(venueList.Where(a => a.name == input.name).FirstOrDefault().id));
            var tips = srv.GetVenueTips(venueList.FirstOrDefault().id, null);

            return(tips);
        }
Beispiel #3
0
        public Venue  SearchVenueByName(VenueSearch input)
        {
            List <Parameter> parameters = new List <Parameter>();

            if (!string.IsNullOrEmpty(input.location.near))
            {
                parameters.Add(new Parameter
                {
                    KeyName  = "near",
                    KeyValue = input.location.near
                });
            }
            else
            {
                if (!string.IsNullOrEmpty(input.location.latitude) && !string.IsNullOrEmpty(input.location.longtitude))
                {
                    parameters.Add(new Parameter
                    {
                        KeyName  = "ll",
                        KeyValue = input.location.latitude.Replace(',', '.') + "," + input.location.longtitude.Replace(',', '.')
                    });
                }
            }
            if (!string.IsNullOrEmpty(input.name))
            {
                parameters.Add(new Parameter
                {
                    KeyName  = "query",
                    KeyValue = input.name
                });
            }
            FoursquareBusiness.Service srv = new FoursquareBusiness.Service(clientId, clientSecret);
            var venueData = srv.SearchVenues(parameters).FirstOrDefault();

            return(venueData);
        }