예제 #1
0
        public async Task <JsonResult> SearchBusiness(string cityId = null, string groupId = null, int?count = null, string searchWord = null)
        {
            var currentCityId = cityId ?? (Session["currentCity"] as City)?.Id;
            var restaurants   = (await _SearchBusiness(cityId: currentCityId, groupId: groupId, count: count, searchWord: searchWord).ToArrayAsync()).Select(
                r =>
                new RestaurantViewModel
            {
                Id   = r.Id,
                Name = r.Name,
                ImageFullFileName = r.ImageFullFileName,
                Place             = new PlaceViewModel {
                    Id = r.Place.Id, Name = r.Place.Name, City = new CityViewModel {
                        Id = r.Place.City.Id, Name = r.Place.City.Name
                    }
                },
                Cuisines = r.Cuisines.Select(c => new CuisineViewModel {
                    Name = c.Name
                }).ToArray(),
                Groups = r.Groups.Select(g => new RestaurantGroupViewModel {
                    Id = g.Id, Name = g.Name
                }).ToArray(),
                Votes = r.Votes.Select(v => new VoteViewModel {
                    ReviewText = v.ReviewText, ApplicationUser = new UserViewModel {
                        Id = v.ApplicationUser.Id, UserName = v.ApplicationUser.UserName, ImageFullFileName = v.ApplicationUser.ImageFullFileName, ReviewsCount = v.ApplicationUser.Votes.Count
                    }
                }).OrderByDescending(o => o.ApplicationUser.ReviewsCount).ToArray(),
                PercentRate = r.PercentRate
            }).OrderByDescending(o => o.PercentRate);

            return(Json(JsonResponseFactory.SuccessResponse(restaurants), JsonRequestBehavior.AllowGet));
        }
예제 #2
0
        public async Task <JsonResult> SearchByKeyword(string searchWord = null, string cityId = null, string groupId = null, string type = null)
        {
            var currentCityId = cityId ?? (Session["currentCity"] as City)?.Id;
            var places        = _db.Places.Where(r => r.Name.Contains(searchWord) && string.Equals(r.City.Id, currentCityId))
                                .Select(p => new SerpItem
            {
                Id        = p.Id.ToString(),
                Name      = p.Name,
                Type      = SerpItemType.Neighbourhood.ToString(),
                PlaceName = string.Empty
            });

            var res = await(string.Equals(type, "loc") ? places :
                            places
                            .Union(_SearchBusiness(cityId: currentCityId, searchWord: searchWord, groupId: groupId).Select(r => new SerpItem
            {
                Id        = r.Id.ToString(),
                Name      = r.Name,
                Type      = SerpItemType.Business.ToString(),
                PlaceName = r.Place.Name
            }))
                            .Union(_searchCuisines(searchWord).Select(c => new SerpItem
            {
                Id        = c.Id,
                Name      = c.Name,
                Type      = SerpItemType.Cuisine.ToString(),
                PlaceName = string.Empty
            }))
                            ).ToArrayAsync();

            return(Json(JsonResponseFactory.SuccessResponse(res), JsonRequestBehavior.AllowGet));
        }
예제 #3
0
 public JsonResult Post(MessagePostViewModel model)
 {
     // TODO: Implement logic
     return(Json(!ModelState.IsValid ? JsonResponseFactory.SuccessResponse() : JsonResponseFactory.ErrorResponse("Some error")));
 }