Example #1
0
        private List <RestaurantSearchDetails> GetRestaurantDetailsBasedOnRating(AddtitionalFeatureForSearch searchList)
        {
            List <RestaurantSearchDetails> restaurants = new List <RestaurantSearchDetails>();

            try
            {
                var restaurantFilter = (from restaurant in db.TblRestaurant
                                        join location in db.TblLocation on restaurant.TblLocationId equals location.Id
                                        select new { TblRestaurant = restaurant, TblLocation = location });

                if (!string.IsNullOrEmpty(searchList.cuisine))
                {
                    restaurantFilter = (from filteredRestaurant in restaurantFilter
                                        join offer in db.TblOffer on filteredRestaurant.TblRestaurant.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
                                        where cuisine.Cuisine.Contains(searchList.cuisine)
                                        select filteredRestaurant).Distinct();
                }
                if (!string.IsNullOrEmpty(searchList.Menu))
                {
                    restaurantFilter = (from filteredRestaurant in restaurantFilter
                                        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(searchList.Menu)
                                        select filteredRestaurant).Distinct();
                    restaurantFilter.ToList().Count();
                }

                if (searchList.rating > 0)
                {
                    restaurantFilter = (from filteredRestaurant in restaurantFilter
                                        join rating in db.TblRating on filteredRestaurant.TblRestaurant.Id equals rating.TblRestaurantId
                                        where rating.Rating.Contains(searchList.rating.ToString())
                                        select filteredRestaurant).Distinct();
                }

                foreach (var item in restaurantFilter)
                {
                    RestaurantSearchDetails restaurant = new RestaurantSearchDetails
                    {
                        restauran_ID           = item.TblRestaurant.Id,
                        restaurant_Name        = item.TblRestaurant.Name,
                        restaurant_Address     = item.TblRestaurant.Address,
                        restaurant_PhoneNumber = item.TblRestaurant.ContactNo,
                        restraurant_Website    = item.TblRestaurant.Website,
                        closing_Time           = item.TblRestaurant.CloseTime,
                        opening_Time           = item.TblRestaurant.OpeningTime,
                        xaxis = (double)item.TblLocation.X,
                        yaxis = (double)item.TblLocation.Y
                    };
                    restaurants.Add(restaurant);
                }
                return(restaurants);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public IQueryable <RestaurantSearchDetails> GetRestaurantsBasedOnMenu(AddtitionalFeatureForSearch searchDetails)
        {
            List <RestaurantSearchDetails> restaurants = new List <RestaurantSearchDetails>();

            try
            {
                restaurants = GetRestaurantDetailsBasedOnRating(searchDetails);
                return(restaurants.AsQueryable());
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
 public IQueryable <RestaurantInformation> SearchForRestaurant(SearchForRestaurant searchDetails)
 {
     try
     {
         List <RestaurantInformation>         restaurantInformationList = new List <RestaurantInformation>();
         DataLayer.DataEntity.LocationDetails locationDetails           = new DataLayer.DataEntity.LocationDetails()
         {
             restaurant_Name = searchDetails.location.restaurant_Name,
             distance        = searchDetails.location.distance,
             xaxis           = searchDetails.location.xaxis,
             yaxis           = searchDetails.location.yaxis
         };
         DataLayer.DataEntity.AddtitionalFeatureForSearch addtitionalFeatureForSearch = new AddtitionalFeatureForSearch()
         {
             cuisine = searchDetails.search.cuisine,
             Menu    = searchDetails.search.Menu,
             rating  = searchDetails.search.rating
         };
         DataLayer.DataEntity.SearchForRestautrant searchForRestautrant = new SearchForRestautrant()
         {
             location = locationDetails,
             search   = addtitionalFeatureForSearch
         };
         IQueryable <RestaurantSearchDetails> searchedRestaurants = search_Repository.SearchForRestaurant(searchForRestautrant);
         if (searchedRestaurants != null)
         {
             foreach (var restaurant in searchedRestaurants)
             {
                 RestaurantInformation restaurantDetails = new RestaurantInformation
                 {
                     restaurant_ID        = restaurant.restauran_ID,
                     restaurant_Name      = restaurant.restaurant_Name,
                     restaurant_Address   = restaurant.restaurant_Address,
                     restaurant_ContactNo = restaurant.restaurant_PhoneNumber,
                     website      = restaurant.restraurant_Website,
                     opening_Time = restaurant.opening_Time,
                     closing_Time = restaurant.closing_Time,
                     xaxis        = restaurant.xaxis,
                     yaxis        = restaurant.yaxis
                 };
                 restaurantInformationList.Add(restaurantDetails);
             }
         }
         return(restaurantInformationList.AsQueryable());
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }