Esempio n. 1
0
        public Businesses GetBusiness(string longitude, string latitude, string search)
        {
            try
            {
                BusinessService businessService = new BusinessService();
                Location location = new Location();
                location.Latitude = latitude;
                location.Longitude = longitude;
                if(!search.ToLower().Trim().Equals("null"))
                    location.BusinessName = search;

                Logging.WriteToFileLog(string.Format( "long : {0} , lat : {1}, search : {2}", longitude, latitude, search));

                // Serialize the results as JSON
                /*DataContractJsonSerializer serializer = new DataContractJsonSerializer(results.GetType());
                MemoryStream memoryStream = new MemoryStream();
                serializer.WriteObject(memoryStream, results);

                // Return the results serialized as JSON
                string json = Encoding.Default.GetString(memoryStream.ToArray());
                return json;
                */

                WebOperationContext.Current.OutgoingResponse.ContentType = "text/plain";
                return new Businesses() { businesses = businessService.BusinessGet(location).ToArray() };
            }
            catch (Exception e)
            {
                Logging.WriteToEventLog("Business GetBusiness " + e.Message);
            }
            return null;
        }
Esempio n. 2
0
 public List<Business> GetBusiness(string longitude, string latitude)
 {
     BusinessService businessService = new BusinessService();
     Location location = new Location();
     location.Latitude = latitude;
     location.Longitude = longitude;
     return businessService.BusinessGet(location);
 }
Esempio n. 3
0
        public void BusinessGetWithDB()
        {
            BusinessService bs = new BusinessService();

            Location loc = new Location();
            //loc.Category = "bars";
            //loc.Latitude = "47.57434809999999";
            //loc.Longitude = "-122.1248621";
            loc.CityName = "bothell";
            loc.Zipcode = "98021";
            loc.Radius = "1";
            loc.BusinessName = "panera";

            bs.BusinessGet(loc);
        }
Esempio n. 4
0
        public string GetMyBusiness(string longitude, string latitude)
        {
            BusinessService businessService = new BusinessService();
            Location location = new Location();
            location.Latitude = latitude;
            location.Longitude = longitude;
            List<Business> businesses = businessService.BusinessGet(location);
            // Serialize the results as JSON
            DataContractJsonSerializer serializer = new DataContractJsonSerializer(businesses.GetType());
            MemoryStream memoryStream = new MemoryStream();
            serializer.WriteObject(memoryStream, businesses);

            // Return the results serialized as JSON
            string json = Encoding.Default.GetString(memoryStream.ToArray());
            return json;
        }
Esempio n. 5
0
        //only get sponsors
        public Businesses GetBusiness(string latitude, string longitude)
        {
            try
            {
                BusinessService businessService = new BusinessService();
                Location location = new Location();
                location.Latitude = latitude;
                location.Longitude = longitude;
                location.Radius = ConfigurationManager.AppSettings["SponsoredRadius"];
                Logging.WriteToFileLog(string.Format( "long : {0} , lat : {1}", longitude, latitude));

                //WebOperationContext.Current.OutgoingResponse.ContentType = "text/plain";
                return new Businesses() { businesses = businessService.BusinessGet(location).ToArray() };
            }
            catch (Exception e)
            {
                Logging.WriteToEventLog("Business GetBusiness " + e.Message);
            }
            return null;
        }
Esempio n. 6
0
        public void BusinessGetWithMock()
        {
            IBusinessResource br = new YelpBusinessResource();
            //br = new BusinessResource();

            BusinessService bs = new BusinessService(
                "http://api.yelp.com/business_review_search?limit=20&ywsid=HJPpruk8klLzsyUyumugXA"
                , br);

            Location loc = new Location();
            //loc.Category = "bars";
            //loc.Latitude = "47.57434809999999";
            //loc.Longitude = "-122.1248621";
            loc.CityName = "bothell";
            loc.Zipcode = "98021";
            loc.Radius = "1";
            loc.BusinessName = "panera";

            bs.BusinessGet(loc);
        }
Esempio n. 7
0
        public Businesses AddBusiness(string businessids)
        {
            try
            {
                Logging.WriteToFileLog(string.Format("businesses ids : {0}", businessids));
                if (!string.IsNullOrEmpty(businessids.Trim()))
                {
                    List<Business> businesses = new List<Business>();
                    businessids.Trim().Split(",".ToCharArray(),StringSplitOptions.RemoveEmptyEntries).ToList().ForEach(x => businesses.Add(new Business() { ExternalID = x }));

                    Logging.WriteToFileLog(string.Format("businesses count : {0}", businesses.Count));
                    BusinessService businessService = new BusinessService();
                    WebOperationContext.Current.OutgoingResponse.ContentType = "text/plain";
                    return new Businesses() { businesses = businessService.BusinessGet(businesses).ToArray() };
                }
            }
            catch (Exception e)
            {
                Logging.WriteToEventLog("Business GetBusiness " + e.Message);
            }
            return null;
        }
Esempio n. 8
0
 static List<Business> GetBusiness()
 {
     BusinessService bs = new BusinessService();
     return bs.BusinessGet(new Location() { Latitude = "1", Longitude = "2" });
 }