Exemple #1
0
        public IQueryable <RestaurantInformation> SearchForRestaurants(SearchForRestaurant searchDetails)
        {
            try
            {
                DataLayer.DataEntity.LocationDetails location_Details = new DataLayer.DataEntity.LocationDetails
                {
                    distance        = searchDetails.location.distance,
                    restaurant_Name = searchDetails.location.restaurant_Name,
                    xaxis           = searchDetails.location.xaxis,
                    yaxis           = searchDetails.location.yaxis
                };

                DataLayer.DataEntity.AddtitionalFeatureForSearch searchForRestaurant = new DataLayer.DataEntity.AddtitionalFeatureForSearch
                {
                    cuisine = (string.IsNullOrEmpty(searchDetails.search.cuisine) ? "" : searchDetails.search.cuisine),
                    Menu    = (string.IsNullOrEmpty(searchDetails.search.Menu) ? "" : searchDetails.search.Menu),
                    rating  = (searchDetails.search.rating != null && searchDetails.search.rating > 0) ? searchDetails.search.rating : 0
                };

                DataLayer.DataEntity.SearchForRestautrant restaurant = new DataLayer.DataEntity.SearchForRestautrant
                {
                    location = location_Details,
                    search   = searchForRestaurant
                };

                List <RestaurantInformation>         restaurant_Info = new List <RestaurantInformation>();
                IQueryable <RestaurantSearchDetails> searched_Restaurant;
                searched_Restaurant = search_Repository.SearchForRestaurants(restaurant);

                //Result
                if (searched_Restaurant != null)
                {
                    foreach (var restaurants in searched_Restaurant)
                    {
                        RestaurantInformation restaurant_Details = new RestaurantInformation
                        {
                            restaurant_ID        = restaurants.restauran_ID,
                            restaurant_Name      = restaurants.restaurant_Name,
                            restaurant_Address   = restaurants.restaurant_Address,
                            restaurant_ContactNo = restaurants.restaurant_PhoneNumber,
                            closing_Time         = restaurants.closing_Time,
                            opening_Time         = restaurants.opening_Time,
                            website = restaurants.restraurant_Website,
                            xaxis   = restaurants.xaxis,
                            yaxis   = restaurants.yaxis
                        };
                        restaurant_Info.Add(restaurant_Details);
                    }
                }
                return(restaurant_Info.AsQueryable());
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public IQueryable <RestaurantInformation> GetRestaurantsBasedOnMenu(AdditionalFeatureForSearch additionalFeatureForSearch)
        {
            try
            {
                List <RestaurantInformation>                     restaurant_Info = new List <RestaurantInformation>();
                IQueryable <RestaurantSearchDetails>             searched_Restaurant;
                DataLayer.DataEntity.AddtitionalFeatureForSearch searchCritera = new DataLayer.DataEntity.AddtitionalFeatureForSearch
                {
                    cuisine = (string.IsNullOrEmpty(additionalFeatureForSearch.cuisine) ? "" : additionalFeatureForSearch.cuisine),
                    Menu    = (string.IsNullOrEmpty(additionalFeatureForSearch.Menu) ? "" : additionalFeatureForSearch.Menu),
                    rating  = (additionalFeatureForSearch.rating != null && additionalFeatureForSearch.rating > 0) ? additionalFeatureForSearch.rating : 0
                };

                searched_Restaurant = search_Repository.GetRestaurantsBasedOnMenu(searchCritera);
                if (searched_Restaurant != null)
                {
                    foreach (var restaurants in searched_Restaurant)
                    {
                        RestaurantInformation restaurant_Details = new RestaurantInformation
                        {
                            restaurant_ID        = restaurants.restauran_ID,
                            restaurant_Name      = restaurants.restaurant_Name,
                            restaurant_Address   = restaurants.restaurant_Address,
                            restaurant_ContactNo = restaurants.restaurant_PhoneNumber,
                            closing_Time         = restaurants.closing_Time,
                            opening_Time         = restaurants.opening_Time,
                            website = restaurants.restraurant_Website,
                            xaxis   = restaurants.xaxis,
                            yaxis   = restaurants.yaxis
                        };
                        restaurant_Info.Add(restaurant_Details);
                    }
                }


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