Beispiel #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;
            }
        }
Beispiel #2
0
        private List <RestaurantSearchDetails> GetRetaurantBasedOnLocationAndName(LocationDetails location_Details)
        {
            List <RestaurantSearchDetails> restaurants = new List <RestaurantSearchDetails>();

            try
            {
                var restaurantInfo = (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(location_Details.restaurant_Name))
                {
                    restaurantInfo = restaurantInfo.Where(a => a.TblRestaurant.Name.Contains(location_Details.restaurant_Name));
                }

                if (!(double.IsNaN(location_Details.xaxis)) && !(double.IsNaN(location_Details.yaxis)))
                {
                    foreach (var place in restaurantInfo)
                    {
                        place.TblLocation.X = Convert.ToDecimal(string.IsNullOrEmpty(place.TblLocation.X.ToString()) ? "0.00" : place.TblLocation.X.ToString());
                        place.TblLocation.Y = Convert.ToDecimal(string.IsNullOrEmpty(place.TblLocation.Y.ToString()) ? "0.00" : place.TblLocation.Y.ToString());

                        double distance = Distance(location_Details.xaxis, location_Details.yaxis, (double)place.TblLocation.X, (double)place.TblLocation.Y);
                        if (distance <= int.Parse(location_Details.distance.ToString()))
                        {
                            RestaurantSearchDetails tblRestaurant = new RestaurantSearchDetails
                            {
                                restauran_ID           = place.TblRestaurant.Id,
                                restaurant_Name        = string.IsNullOrEmpty(place.TblRestaurant.Name) ? string.Empty : place.TblRestaurant.Name,
                                restaurant_Address     = string.IsNullOrEmpty(place.TblRestaurant.Address) ? string.Empty : place.TblRestaurant.Address,
                                restaurant_PhoneNumber = string.IsNullOrEmpty(place.TblRestaurant.ContactNo) ? string.Empty : place.TblRestaurant.ContactNo,
                                restraurant_Website    = string.IsNullOrEmpty(place.TblRestaurant.Website) ? string.Empty : place.TblRestaurant.Website,
                                closing_Time           = string.IsNullOrEmpty(place.TblRestaurant.CloseTime) ? string.Empty : place.TblRestaurant.CloseTime,
                                opening_Time           = string.IsNullOrEmpty(place.TblRestaurant.OpeningTime) ? string.Empty : place.TblRestaurant.OpeningTime,
                                xaxis = Convert.ToDouble(place.TblLocation.X),
                                yaxis = Convert.ToDouble(place.TblLocation.Y)
                            };
                            restaurants.Add(tblRestaurant);
                        }
                    }
                }
                return(restaurants);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Beispiel #3
0
        private List <RestaurantSearchDetails> GetResturantDetailsBasedOnMutipleParams(SearchForRestautrant searchDetails)

        {
            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
                                        join rating in db.TblRating on restaurant.Id equals rating.TblRestaurantId
                                        select new { TblRestaurant = restaurant, TblLocation = location, TblRating = rating });



                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(searchDetails.search.cuisine) || menu.Item.Contains(searchDetails.search.Menu) || filteredRestaurant.TblRating.Rating.Contains(searchDetails.search.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,
                        Rating = int.Parse(item.TblRating.Rating)
                    };
                    restaurants.Add(restaurant);
                }


                return(restaurants);
            }
            catch (Exception ex)
            {
                return(restaurants);
            }
        }
Beispiel #4
0
        private List <RestaurantSearchDetails> GetRetaurantBasedOnLocationAndName(LocationDetails location_Details)
        {
            List <RestaurantSearchDetails> restaurants = new List <RestaurantSearchDetails>();

            try
            {
                var restaurantInfo = (from restaurant in db.TblRestaurant
                                      join location in db.TblLocation on restaurant.TblLocationId equals location.Id
                                      join rating in db.TblRating on restaurant.Id equals rating.TblRestaurantId
                                      orderby rating.Rating descending
                                      select new { TblRestaurant = restaurant, TblLocation = location });

                if (!string.IsNullOrEmpty(location_Details.restaurant_Name))
                {
                    restaurantInfo = restaurantInfo.Where(a => a.TblRestaurant.Name.Contains(location_Details.restaurant_Name));
                }

                if (!(double.IsNaN(location_Details.xaxis)) && !(double.IsNaN(location_Details.yaxis)))
                {
                    foreach (var place in restaurantInfo)
                    {
                        double distance = Distance(location_Details.xaxis, location_Details.yaxis, place.TblLocation.X.HasValue ? (double)place.TblLocation.X : 0, place.TblLocation.Y.HasValue ? (double)place.TblLocation.Y : 0);
                        if (distance < int.Parse(location_Details.distance.ToString()))
                        {
                            RestaurantSearchDetails tblRestaurant = new RestaurantSearchDetails
                            {
                                restauran_ID           = place.TblRestaurant.Id,
                                restaurant_Name        = place.TblRestaurant.Name,
                                restaurant_Address     = place.TblRestaurant.Address,
                                restaurant_PhoneNumber = place.TblRestaurant.ContactNo,
                                restraurant_Website    = place.TblRestaurant.Website,
                                closing_Time           = place.TblRestaurant.CloseTime,
                                opening_Time           = place.TblRestaurant.OpeningTime,
                                xaxis = place.TblLocation.X.HasValue ? (double)place.TblLocation.X : 0,
                                yaxis = place.TblLocation.Y.HasValue ? (double)place.TblLocation.Y : 0
                            };
                            restaurants.Add(tblRestaurant);
                        }
                    }
                }
                return(restaurants);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Beispiel #5
0
        public IQueryable <RestaurantSearchDetails> GetRestaurantsBasedOnRatingOrder()
        {
            List <RestaurantSearchDetails> restaurants = new List <RestaurantSearchDetails>();

            try
            {
                //GetRestaurantsBasedOnLocation(searchDetails.location);
                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 (!(double.IsNaN(searchDetails.location.xaxis)) && !(double.IsNaN(searchDetails.location.yaxis)))
                //{
                foreach (var place in restaurantFilter)
                {
                    //        double distance = Distance(searchDetails.location.xaxis, searchDetails.location.yaxis, (double)place.TblLocation.X, (double)place.TblLocation.Y);
                    //        if (distance > int.Parse(searchDetails.location.distance.ToString()))
                    {
                        restaurantFilter = (from filteredRestaurant in restaurantFilter
                                            join rating in db.TblRating on filteredRestaurant.TblRestaurant.Id equals rating.TblRestaurantId
                                            orderby rating.Rating
                                            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.AsQueryable());
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Beispiel #6
0
        public IQueryable <RestaurantSearchDetails> SearchForRestaurantWithHigherRatingsFirst()
        {
            try
            {
                if (db != null)
                {
                    var restaurantFilter = (from restaurant in db.TblRestaurant
                                            join location in db.TblLocation on restaurant.TblLocationId equals location.Id
                                            select new { TblRestaurant = restaurant, TblLocation = location });

                    restaurantFilter = (from restaurant in restaurantFilter
                                        join rating in db.TblRating on restaurant.TblRestaurant.Id equals rating.TblRestaurantId
                                        orderby rating.Rating descending
                                        select restaurant);

                    List <RestaurantSearchDetails> restaurants = new List <RestaurantSearchDetails>();
                    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 = Convert.ToDouble(string.IsNullOrEmpty(item.TblLocation.X.ToString()) ? "0.00" : item.TblLocation.X.ToString()),
                            yaxis = Convert.ToDouble(string.IsNullOrEmpty(item.TblLocation.Y.ToString()) ? "0.00" : item.TblLocation.Y.ToString())
                        };
                        restaurants.Add(restaurant);
                    }
                    return(restaurants.AsQueryable());
                }
                return(null);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Beispiel #7
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;
            }
        }
        private List <RestaurantSearchDetails> GetRestaurantDetailsBasedOnMultipleOptions(SearchForRestautrant searchDetails)
        {
            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
                                        join rating in db.TblRating on restaurant.Id equals rating.TblRestaurantId
                                        join offer in db.TblOffer on restaurant.Id equals offer.TblRestaurantId
                                        join menu in db.TblMenu on offer.TblMenuId equals menu.Id
                                        join cousine in db.TblCuisine on menu.TblCuisineId equals cousine.Id
                                        select new { TblRestaurant = restaurant, TblLocation = location, TblRating = rating,
                                                     TblOffer = offer, TblMenu = menu, TblCuisine = cousine });

                if (!string.IsNullOrEmpty(searchDetails.location.restaurant_Name))
                {
                    restaurantFilter = (from filteredRestaurant in restaurantFilter
                                        where filteredRestaurant.TblRestaurant.Name.Contains(searchDetails.location.restaurant_Name)
                                        select filteredRestaurant);
                }

                if ((searchDetails.location.xaxis > 0) && (searchDetails.location.yaxis > 0))
                {
                    restaurantFilter = (from filteredRestaurant in restaurantFilter
                                        where Convert.ToDouble(filteredRestaurant.TblLocation.X) <= searchDetails.location.xaxis &&
                                        Convert.ToDouble(filteredRestaurant.TblLocation.Y) <= searchDetails.location.yaxis
                                        select filteredRestaurant);

                    if (searchDetails.location.distance > 0 && searchDetails.location.distance <= calculateDistanceUsingCordinates(searchDetails.location.xaxis, searchDetails.location.yaxis))
                    {
                        //TBD
                    }
                }

                if (searchDetails.search.rating > 0)
                {
                    restaurantFilter = (from filteredRestaurant in restaurantFilter
                                        where Convert.ToInt32(filteredRestaurant.TblRating.Rating) <= searchDetails.search.rating
                                        select filteredRestaurant);
                }

                if (!string.IsNullOrEmpty(searchDetails.search.Menu))
                {
                    restaurantFilter = (from filteredRestaurant in restaurantFilter
                                        where filteredRestaurant.TblMenu.Item.Contains(searchDetails.search.Menu)
                                        select filteredRestaurant);
                }

                if (!string.IsNullOrEmpty(searchDetails.search.cuisine))
                {
                    restaurantFilter = (from filteredRestaurant in restaurantFilter
                                        where filteredRestaurant.TblCuisine.Cuisine.Contains(searchDetails.search.cuisine)
                                        select filteredRestaurant);
                }

                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;
            }
        }
Beispiel #9
0
        private List <RestaurantSearchDetails> GetRetaurantBasedOnLocationAndName(LocationDetails location_Details)
        {
            List <RestaurantSearchDetails> restaurants = new List <RestaurantSearchDetails>();

            try
            {
                var restaurantInfo = (from restaurant in db.TblRestaurant
                                      join location in db.TblLocation on restaurant.TblLocationId equals location.Id
                                      select new { TblRestaurant = restaurant, TblLocation = location });
                restaurantInfo = (from filteredRestaurant in restaurantInfo
                                  join rating in db.TblRating on filteredRestaurant.TblRestaurant.Id equals rating.TblRestaurantId
                                  orderby rating descending
                                  select filteredRestaurant);

                if (!string.IsNullOrEmpty(location_Details.restaurant_Name))
                {
                    restaurantInfo = restaurantInfo.Where(a => a.TblRestaurant.Name.Contains(location_Details.restaurant_Name));
                }

                if (!(location_Details.xaxis <= 0) || (location_Details.yaxis < 0))
                {
                    foreach (var place in restaurantInfo)
                    {
                        double distance = Distance(location_Details.xaxis, location_Details.yaxis, (double)place.TblLocation.X, (double)place.TblLocation.Y);
                        if (distance < int.Parse(location_Details.distance.ToString()))
                        {
                            RestaurantSearchDetails tblRestaurant = new RestaurantSearchDetails
                            {
                                restauran_ID         = place.TblRestaurant.Id,
                                restaurant_Name      = place.TblRestaurant.Name,
                                restaurant_Address   = place.TblRestaurant.Address,
                                restaurant_ContactNo = place.TblRestaurant.ContactNo,
                                website      = place.TblRestaurant.Website,
                                closing_Time = place.TblRestaurant.CloseTime,
                                opening_Time = place.TblRestaurant.OpeningTime,
                                xaxis        = (double)place.TblLocation.X,
                                yaxis        = (double)place.TblLocation.Y
                            };
                            restaurants.Add(tblRestaurant);
                        }
                    }
                }
                else
                {
                    foreach (var item in restaurantInfo)
                    {
                        RestaurantSearchDetails tblRestaurant = new RestaurantSearchDetails
                        {
                            restauran_ID         = item.TblRestaurant.Id,
                            restaurant_Name      = item.TblRestaurant.Name,
                            restaurant_Address   = item.TblRestaurant.Address,
                            restaurant_ContactNo = item.TblRestaurant.ContactNo,
                            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(tblRestaurant);
                    }
                }
                return(restaurants);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Beispiel #10
0
        public IQueryable <RestaurantSearchDetails> TotalSearchForRestaurant(SearchForRestautrant searchDetails)
        {
            List <RestaurantSearchDetails> restaurants = new List <RestaurantSearchDetails>();

            try
            {
                var res = db.TblRestaurant.Include(x => x.TblRating);

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


                if (searchDetails.search != null)
                {
                    if (!string.IsNullOrEmpty(searchDetails.search.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(searchDetails.search.cuisine)
                                            select filteredRestaurant).Distinct();
                    }
                    if (!string.IsNullOrEmpty(searchDetails.search.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(searchDetails.search.Menu)
                                            select filteredRestaurant).Distinct();
                    }

                    if (searchDetails.search.budget > 0)

                    {
                        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 offer.Price > searchDetails.search.budget
                                            select filteredRestaurant).Distinct();
                    }
                    if (searchDetails.search.rating > 0)
                    {
                        restaurantFilter = (from filteredRestaurant in restaurantFilter
                                            join rating in db.TblRating on filteredRestaurant.TblRestaurant.Id equals rating.TblRestaurantId
                                            where rating.Rating.Contains(searchDetails.search.rating.ToString())
                                            select filteredRestaurant).Distinct();
                    }
                }
                if (searchDetails.location != null)
                {
                    if (!string.IsNullOrEmpty(searchDetails.location.restaurant_Name))
                    {
                        restaurantFilter = restaurantFilter.Where(a => a.TblRestaurant.Name.Contains(searchDetails.location.restaurant_Name));
                    }

                    if (!(searchDetails.location.xaxis <= 0) || (searchDetails.location.yaxis < 0))
                    {
                        foreach (var place in restaurantFilter)
                        {
                            double distance = Distance(searchDetails.location.xaxis, searchDetails.location.yaxis, (double)place.TblLocation.X, (double)place.TblLocation.Y);
                            if (distance < int.Parse(searchDetails.location.distance.ToString()))
                            {
                                RestaurantSearchDetails tblRestaurant = new RestaurantSearchDetails
                                {
                                    restauran_ID         = place.TblRestaurant.Id,
                                    restaurant_Name      = place.TblRestaurant.Name,
                                    restaurant_Address   = place.TblRestaurant.Address,
                                    restaurant_ContactNo = place.TblRestaurant.ContactNo,
                                    website      = place.TblRestaurant.Website,
                                    closing_Time = place.TblRestaurant.CloseTime,
                                    opening_Time = place.TblRestaurant.OpeningTime,
                                    xaxis        = (double)place.TblLocation.X,
                                    yaxis        = (double)place.TblLocation.Y
                                };
                                try
                                {
                                    tblRestaurant.rating = place.TblRestaurant.TblRating.Average(x => Convert.ToDecimal(x.Rating));
                                }
                                catch
                                {
                                    tblRestaurant.rating = 0;
                                }
                                restaurants.Add(tblRestaurant);
                            }
                        }
                    }
                    else
                    {
                        foreach (var item in restaurantFilter)
                        {
                            RestaurantSearchDetails tblRestaurant = new RestaurantSearchDetails
                            {
                                restauran_ID         = item.TblRestaurant.Id,
                                restaurant_Name      = item.TblRestaurant.Name,
                                restaurant_Address   = item.TblRestaurant.Address,
                                restaurant_ContactNo = item.TblRestaurant.ContactNo,
                                website      = item.TblRestaurant.Website,
                                closing_Time = item.TblRestaurant.CloseTime,
                                opening_Time = item.TblRestaurant.OpeningTime,
                                xaxis        = (double)item.TblLocation.X,
                                yaxis        = (double)item.TblLocation.Y
                            };

                            try
                            {
                                tblRestaurant.rating = item.TblRestaurant.TblRating.Average(x => Convert.ToDecimal(x.Rating));
                            }
                            catch
                            {
                                tblRestaurant.rating = 0;
                            }
                            restaurants.Add(tblRestaurant);
                        }
                    }
                }
                return(restaurants.DistinctBy(x => x.restaurant_Name).AsQueryable().OrderByDescending(x => x.rating));
            }
            catch (Exception ex)
            {
                return(null);
            }
        }