public IHttpActionResult Search(string search = "", string city = "", int?stateProvinceId = null, int?countryId = null)
        {
            var businessResults = _businessPageService.Search(search, city, stateProvinceId, countryId);

            var results = new List <object>();

            foreach (var item in businessResults)
            {
                var state             = _stateService.Get(x => x.Id == item.StateId).FirstOrDefault();
                var stateAbbreviation = (state != null) ? state.Abbreviation : string.Empty;

                var picture    = item.GetPictures().FirstOrDefault();
                var pictureUrl = _mediaService.GetPictureUrl(picture, returnDefaultIfNotFound: true);

                results.Add(new {
                    Title        = item.Name,
                    Subtitle     = item.Address1 + " " + item.City + ", " + stateAbbreviation,
                    SeName       = item.GetPermalink().Slug,
                    ThumbnailUrl = pictureUrl
                });
            }

            return(RespondSuccess(new
            {
                BusinessPages = results
            }));
        }
Ejemplo n.º 2
0
        public ActionResult Search(string nameKeyword, string city, int?stateProvinceId, int?countryId)
        {
            var businessResults = _businessPageService.Search(nameKeyword, city, stateProvinceId, countryId);

            var results = new List <object>();

            foreach (var item in businessResults)
            {
                var state             = _stateProvinceService.GetStateProvinceById(item.StateProvinceId);
                var stateAbbreviation = (state != null) ? state.Abbreviation : string.Empty;

                var picture = _businessPageService.GetFirstPicture(item.Id);

                results.Add(new
                {
                    Title        = item.Name,
                    Subtitle     = item.Address1 + " " + item.City + ", " + stateAbbreviation,
                    Url          = Url.RouteUrl("BusinessPageUrl", new { SeName = item.GetSeName() }),
                    ThumbnailUrl = _pictureService.GetPictureUrl(picture, 75)
                });
            }

            return(Json(results));
        }