/// <summary>
        /// Get Favourite Places
        /// </summary>
        /// <param name="_userID"></param>
        /// <returns></returns>
        public List <FavouritePlaceVM> GetFavouritePlaces(Int32 _userID)
        {
            List <FavouritePlace> _favouritePlaces = _objBusinessDAL.GetFavouritePlaces(_userID);

            if (_favouritePlaces.Count > 0)
            {
                List <FavouritePlaceVM> _listFavouritePlaceVM = new List <FavouritePlaceVM>();
                foreach (FavouritePlace _favouritePlace in _favouritePlaces)
                {
                    FavouritePlaceVM _favouritePlaceVM = MakeFavouritePlaceVM(_favouritePlace);
                    _listFavouritePlaceVM.Add(_favouritePlaceVM);
                }
                return(_listFavouritePlaceVM);
            }
            else
            {
                return(null);
            }
        }
Exemple #2
0
        /// <summary>
        /// Get Favourite Places
        /// </summary>
        /// <param name="_userID"></param>
        /// <returns></returns>
        public List <FavouritePlaceVM> GetFavouritePlaces(Int32 _userID)
        {
            List <FavouritePlace> _favouritePlaces = _objBusinessDAL.GetFavouritePlaces(_userID);

            if (_favouritePlaces.Count > 0)
            {
                List <FavouritePlaceVM> _listFavouritePlaceVM = new List <FavouritePlaceVM>();
                foreach (FavouritePlace _favouritePlace in _favouritePlaces)
                {
                    FavouritePlaceVM _favouritePlaceVM = null;

                    if (_favouritePlace.BusinessID != null)
                    {
                        _favouritePlaceVM = MakeFavouritePlaceVM(_favouritePlace);
                    }
                    else
                    {
                        String googlePlaceURL = ConfigurationManager.AppSettings["GooglePlaceAPIReviewURL"] + _favouritePlace.PlaceID + "&key=" + ConfigurationManager.AppSettings["GooglePlaceAPIKey"];

                        using (var client = new WebClient())
                            using (var stream = client.OpenRead(googlePlaceURL))
                                using (var reader = new StreamReader(stream))
                                    using (var jsonData = new JsonTextReader(reader))
                                    {
                                        _favouritePlaceVM = FavouritePlaceDetailsFromAPI(JObject.Load(jsonData)["result"], _userID);
                                    }
                    }
                    _listFavouritePlaceVM.Add(_favouritePlaceVM);
                }
                return(_listFavouritePlaceVM.OrderBy(b => b.Latitude).ThenBy(b => b.Longitude).ToList());
            }
            else
            {
                return(null);
            }
        }