예제 #1
0
        public async Task<IEnumerable<RestaurantCategoryInfo>> GetCategoryInfoListFor(CityInfo city, FilterOptions filterOptions)
        {
            var cacheKey = (city.ToString() + "GetCategoryInfoListFor");
            if (this._inMemoryCache.Contains(cacheKey))
            {
                return await Task.FromResult<IEnumerable<RestaurantCategoryInfo>>(
                    (IEnumerable<RestaurantCategoryInfo>)this._inMemoryCache[cacheKey]
                );
            }
            else
            {
                var result = await this._dataAccess.GetCategoryInfoListFor(city, filterOptions);

                this._inMemoryCache[cacheKey] = result;

                return result;
            }
        }
예제 #2
0
        public async Task<IEnumerable<RestaurantAmenityInfo>> GetAmenityInfoListFor(CityInfo city, FilterOptions filterOptions)
        {
            var command = new LECommand("GetAmmendityListCount");

            command.AddParam("format", "json");
            command.AddParam("cityid", city.Id);

            if (filterOptions != null)
            {
                foreach (var filterOption in filterOptions.AllOptions)
                {
                    command.AddParam(filterOption.Name, filterOption.Value);
                }
            }

            JObject json = await this.DoGet(command);

            JArray amenityInfos = (JArray)json["AmendityFilterCount"];

            return amenityInfos.Select<JToken, RestaurantAmenityInfo>(jsonToken =>
            {
                return new RestaurantAmenityInfo()
                {
                    Id = (string)jsonToken["AmendityID"],
                    Name = (string)jsonToken["AmendityName"],
                    RestaurantCount = (int)jsonToken["AmendityCount"]
                };
            });
        }
예제 #3
0
        /// <summary>
        /// Given the state info get the cities of that state and return
        /// the state populated with the cities on the gift card program.
        /// </summary>
        /// <param name="stateInfo">The state to get cities for</param>
        /// <returns>The given state with its cities loaded</returns>
        public async Task<StateInfo> GetCities(StateInfo stateInfo)
        {
            // GetCityListByStateID
            var command = new LECommand("GetCityListByStateID");

            //&top = -Indicates how many cities you want to pull back
            //-&format = -Tell it which format you would like the results in. Options are
            //xml and json
            //- &stateId = -Tell it which state to retrieve cities in by ID.
            command.AddParam("top","500");
            command.AddParam("format", "json");
            command.AddParam("stateId", Convert.ToString(stateInfo.Id));

            var json = await this.DoGet(command);

            var cnt = (int)json["Count"];

            if (cnt > 0)
            {
                var citiesArray = (JArray)json["Cities"];

                var cities = citiesArray.Select<JToken, CityInfo>(jt =>{
                    var city = new CityInfo();

                    city.Id = Convert.ToString((int)jt["D_City_ID"]);
                    city.Name = (string)jt["City_Name"];

                    return city;
                }).ToList<CityInfo>();

                stateInfo.Cities = cities;

                return stateInfo;
            }
            else
            {
                stateInfo.Cities = new List<CityInfo>();

                return stateInfo;
            }
        }
예제 #4
0
 /// <summary>
 /// Return the list of amenities in a city along with the count of restaurants in those amenities.
 /// Use the filter options to filter restaurants that are in those amenities.
 /// </summary>
 /// <param name="city">The city to get categories for.</param>
 /// <param name="filterOptions">Restaurant filter options</param>
 /// <returns>Amenity list</returns>
 public async Task<IEnumerable<RestaurantAmenityInfo>> GetAmenityInfoListFor(CityInfo city, FilterOptions filterOptions)
 {
     return await this._leRepository.GetAmenityInfoListFor(city, filterOptions).ConfigureAwait(_configAwait);
 }
예제 #5
0
 /// <summary>
 /// Return the list of neighborhoods in a city along with the count of restaurants in those neighborhoods.
 /// Use the filter options to filter restaurants that are in those neighborhoods.
 /// </summary>
 /// <param name="city">The city to get categories for.</param>
 /// <param name="filterOptions">Restaurant filter options</param>
 /// <returns>Neighborhood list</returns>
 public async Task<IEnumerable<NeighborhoodInfo>> GetNeighborhoodInfoListFor(CityInfo city, FilterOptions filterOptions)
 {
     return await this._leRepository.GetNeighborhoodInfoListFor(city, filterOptions).ConfigureAwait(_configAwait);
 }
예제 #6
0
 /// <summary>
 /// Return a list of restaurants "near by" in a city or geo location with the given
 /// size and skipping the given number of restaurants before returning any restaurants.
 /// Note:  If lat/lon is given then city is ignored and vice versa.
 /// </summary>
 /// <param name="givenSize">The size of the restaurant list expected</param>
 /// <param name="skipping">The restaurants to skip before adding restaurant to list</param>
 /// <param name="lat">Near by latitude</param>
 /// <param name="lon">Near by longitude</param>
 /// <param name="orCity">Near by city</param>
 /// <returns>Restaurant list</returns>
 public async Task<List<RestaurantInfo>> GetRestaurantListNearBy(FilterOptions filterOptions, double? lat = null, double? lon = null, 
                                                                 CityInfo orCity = null, int givenSize = 25, int skipping = 0)
 {
     var orCityId = orCity == null ? null : orCity.Id;
     return await this._leRepository.GetRestaurantListNearBy(filterOptions, lat, lon, orCityId, givenSize, skipping);
 }