Example #1
0
        public IActionResult SearchRestaurantBasedMultipleFactors([FromQuery] MultipleSearchFeature multiplesearch)
        {
            IQueryable <RestaurantInformation> restaurantDetails;

            restaurantDetails = business_Repo.SearchForRestaurantBasedOnMultipleFeactures(multiplesearch);
            if (restaurantDetails != null)
            {
                return(this.Ok(restaurantDetails));
            }
            return(this.StatusCode((int)HttpStatusCode.InternalServerError, string.Empty));
        }
Example #2
0
        public void SearchRestaurantBasedMultipleFactors()
        {
            IQueryable <RestaurantInformation> restaurant_Info = null;
            MultipleSearchFeature multiplesearch = new MultipleSearchFeature
            {
                cuisine = "Florida",
                Menu    = "Dosa",
                rating  = 1
            };

            var mockOrder = new Mock <IRestaurantBusiness>();

            mockOrder.Setup(x => x.SearchForRestaurantBasedOnMultipleFeactures(multiplesearch)).Returns(restaurant_Info.AsQueryable());
            var search = new SearchController(mockOrder.Object);
            var data   = search.SearchRestaurantBasedMultipleFactors(multiplesearch);

            var okObjectResult = data as OkObjectResult;

            Assert.AreEqual(200, okObjectResult.StatusCode);
        }
Example #3
0
        public IQueryable <RestaurantSearchDetails> SearchForRestaurantBasedOnMultipleFeactures(MultipleSearchFeature multiplesearchDetails)
        {
            List <RestaurantSearchDetails> restaurantInfo = new List <RestaurantSearchDetails>();

            try
            {
                var restaurantFilterforMultipleSearch = (from restaurant in db.TblRestaurant
                                                         join location in db.TblLocation on restaurant.TblLocationId equals location.Id
                                                         join offer in db.TblOffer on restaurant.Id equals offer.TblRestaurantId
                                                         join menu in db.TblMenu on offer.TblMenuId equals menu.Id
                                                         join cuisine in db.TblCuisine on menu.TblCuisineId equals cuisine.Id
                                                         join rating in db.TblRating on restaurant.Id equals rating.TblRestaurantId
                                                         orderby rating.Rating descending
                                                         select new { TblRestaurant = restaurant, TblLocation = location, TblCuisine = cuisine });
                if (multiplesearchDetails.rating > 0)
                {
                    restaurantFilterforMultipleSearch = (from filteredRestaurant in restaurantFilterforMultipleSearch
                                                         join rating in db.TblRating on filteredRestaurant.TblRestaurant.Id equals rating.TblRestaurantId
                                                         where rating.Rating.Contains(multiplesearchDetails.rating.ToString())
                                                         select filteredRestaurant).Distinct();
                }
                if (!string.IsNullOrEmpty(multiplesearchDetails.cuisine))
                {
                    restaurantFilterforMultipleSearch = (from filteredRestaurant in restaurantFilterforMultipleSearch
                                                         join cuisine in db.TblCuisine on filteredRestaurant.TblCuisine.Id equals cuisine.Id
                                                         where cuisine.Cuisine.Contains(multiplesearchDetails.cuisine.ToString())
                                                         select filteredRestaurant).Distinct();
                }
                if (!string.IsNullOrEmpty(multiplesearchDetails.Menu))
                {
                    restaurantFilterforMultipleSearch = (from filteredRestaurant in restaurantFilterforMultipleSearch
                                                         join offer in db.TblOffer on filteredRestaurant.TblRestaurant.Id equals offer.TblRestaurantId
                                                         join menu in db.TblMenu on offer.TblMenuId equals menu.Id
                                                         where menu.Item.Contains(multiplesearchDetails.Menu)
                                                         select filteredRestaurant).Distinct();
                }
                if (!string.IsNullOrEmpty(multiplesearchDetails.RestaurantName))
                {
                    restaurantFilterforMultipleSearch = (from filteredRestaurant in restaurantFilterforMultipleSearch
                                                         where filteredRestaurant.TblRestaurant.Name.Contains(multiplesearchDetails.RestaurantName)
                                                         select filteredRestaurant).Distinct();
                }
                foreach (var restaurantinfo in restaurantFilterforMultipleSearch)
                {
                    RestaurantSearchDetails restaurant = new RestaurantSearchDetails
                    {
                        restauran_ID           = restaurantinfo.TblRestaurant.Id,
                        restaurant_Name        = restaurantinfo.TblRestaurant.Name,
                        restaurant_Address     = restaurantinfo.TblRestaurant.Address,
                        restaurant_PhoneNumber = restaurantinfo.TblRestaurant.ContactNo,
                        restraurant_Website    = restaurantinfo.TblRestaurant.Website,
                        closing_Time           = restaurantinfo.TblRestaurant.CloseTime,
                        opening_Time           = restaurantinfo.TblRestaurant.OpeningTime,
                        xaxis = (double)restaurantinfo.TblLocation.X,
                        yaxis = (double)restaurantinfo.TblLocation.Y
                    };
                    restaurantInfo.Add(restaurant);
                }

                return(restaurantInfo.AsQueryable());
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }