Ejemplo n.º 1
0
        public async Task <bool> IsValidRestaurantAsync(RatingandReviewDetails ratingEntity, int UserId, string UserToken)
        {
            //HttpClient client = new HttpClient();
            //client.BaseAddress = new Uri("http://localhost:10603/");
            //HttpResponseMessage httpResponseMessage = await client.GetAsync("api/ResturantDetail?RestaurantID=" + ratingEntity.TblRestaurantId);
            //if(httpResponseMessage.IsSuccessStatusCode)
            //{
            //    string json = await httpResponseMessage.Content.ReadAsStringAsync();
            //    RestaurantInformation restaurantInformation = JsonConvert.DeserializeObject<RestaurantInformation>(json);
            //    if(restaurantInformation!=null)
            //    {
            //        return true;
            //    }
            //}
            //return false;
            using (HttpClient httpClient = WebAPIClient.GetClient(UserToken, UserId, "http://localhost:10603/"))
            {
                HttpResponseMessage httpResponseMessage = await httpClient.GetAsync("api/ResturantDetail?RestaurantID=" + ratingEntity.TblRestaurantId);

                if (httpResponseMessage.IsSuccessStatusCode)
                {
                    string json = await httpResponseMessage.Content.ReadAsStringAsync();

                    RestaurantInformation restaurantInformation = JsonConvert.DeserializeObject <RestaurantInformation>(json);
                    if (restaurantInformation != null)
                    {
                        return(true);
                    }
                }
            }
            return(false);
        }
 public IQueryable <RestaurantInformation> SearchForRestaurantWithHigherRatingsFirst()
 {
     try
     {
         List <RestaurantInformation>         restaurantInformationList = new List <RestaurantInformation>();
         IQueryable <RestaurantSearchDetails> searchedRestaurants       = search_Repository.SearchForRestaurantWithHigherRatingsFirst();
         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;
     }
 }
Ejemplo n.º 3
0
        public void Write(RestaurantInformation objectToList, string fileName)
        {
            SocialTapContext db = new SocialTapContext();

            db.RestaurantInformationTable.Add(objectToList);
            db.SaveChanges();
        }
Ejemplo n.º 4
0
        public static List <RestaurantInformation> GetRestaurantDate()
        {
            RestaurantInformation dataEntry = new RestaurantInformation();
            var dataEntryList = new List <RestaurantInformation>();

            DataSet ds = new DataSet();

            //2nd assignment
            //ds = RestaurantDbAccess.GetDataUsingDB();

            //3rd assignment
            var service = new RestaurantService.RestaurantServiceClient();

            ds = service.GetDataUsingDB();

            if (ds.Tables.Count > 0)
            {
                dataEntryList = ds.Tables[0].AsEnumerable().Select(m => new RestaurantInformation
                {
                    Name         = Convert.ToString(m["Name"]),
                    Country      = Convert.ToString(m["Country"]),
                    City         = Convert.ToString(m["City"]),
                    AwardedSince = Convert.ToString(m["AwardedSince"])
                }).ToList();
            }

            return(dataEntryList);
        }
Ejemplo n.º 5
0
        private async void GetMap()
        {
            GoogleStaticMapApiData nearbyPlacesData = new GoogleStaticMapApiData();
            string type = cmbType.Text;
            string zoom = cmdZoom.Text;

            try
            {
                Bitmap map = await nearbyPlacesData.GetMapResponseDataAsync(type, zoom);

                TblNearbyLocation.Rows.Clear();
                ImageBoxMap.Image  = map;
                lblImageError.Text = "";

                for (int i = 0; i < 5; i++)
                {
                    RestaurantInformation restaurantInfo = new RestaurantInformation();
                    restaurantInfo.Name    = nearbyPlacesData.placesList[i].Name;
                    restaurantInfo.Address = nearbyPlacesData.placesList[i].Address;
                    RestaurantAverageOfPercentage restaurantAverageOfPercentage = new RestaurantAverageOfPercentage();
                    TblNearbyLocation.Rows.Add(i + 1, restaurantInfo.Name, restaurantInfo.Address, restaurantAverageOfPercentage.GetAverageOfLiquid(restaurantInfo));
                }
            }
            catch (ArgumentOutOfRangeException)
            {
                TblNearbyLocation.Rows.Clear();
                ImageBoxMap.Image  = null;
                lblImageError.Text = "Cannot load information";
            }
        }
 public RestaurantInformation GetResturantDetails(int restaurantID)
 {
     try
     {
         TblRestaurant restaurant = new TblRestaurant();
         restaurant = search_Repository.GetResturantDetails(restaurantID);
         RestaurantInformation resturant_Information = new RestaurantInformation
         {
             restaurant_ID        = restaurant.Id,
             restaurant_Name      = restaurant.Name,
             restaurant_Address   = restaurant.Address,
             restaurant_ContactNo = restaurant.ContactNo,
             closing_Time         = restaurant.CloseTime,
             opening_Time         = restaurant.OpeningTime,
             website = restaurant.Website,
             xaxis   = (double)restaurant.TblLocation.X,
             yaxis   = (double)restaurant.TblLocation.Y
         };
         return(resturant_Information);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Ejemplo n.º 7
0
        public RestaurantInformation GetResturantDetail([FromQuery] int RestaurantID)
        {
            RestaurantInformation resturantInformation = new RestaurantInformation();

            resturantInformation = business_Repo.GetResturantDetails(RestaurantID);
            return(resturantInformation);
        }
Ejemplo n.º 8
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;
            }
        }
Ejemplo n.º 9
0
        public void Write(RestaurantInformation glassInformation)
        {
            ReadingFromFile <RestaurantInformation> readingFromFile = new ReadingFromFile <RestaurantInformation>();
            List <RestaurantInformation>            listofGlass     = readingFromFile.Read();
            BinaryFormatter binaryFormatter = new BinaryFormatter();
            FileStream      fileStream      = new FileStream("C:\\data.bin", FileMode.OpenOrCreate, FileAccess.Write, FileShare.None);

            listofGlass.Add(glassInformation);
            binaryFormatter.Serialize(fileStream, listofGlass);
            fileStream.Flush();
            fileStream.Close();
        }
Ejemplo n.º 10
0
        public IQueryable <RestaurantInformation> GetRestaurantsBasedOnOrderRating()
        {
            try
            {
                BusinessEntities.LocationDetails     locationDetails = new BusinessEntities.LocationDetails();
                List <RestaurantInformation>         restaurant_Info = new List <RestaurantInformation>();
                IQueryable <RestaurantSearchDetails> searched_Restaurant;
                //DataLayer.DataEntity.AddtitionalFeatureForSearch searchCritera = new DataLayer.DataEntity.AddtitionalFeatureForSearch
                //{
                //    rating = (additionalFeatureForSearch.rating != null && additionalFeatureForSearch.rating > 0) ? additionalFeatureForSearch.rating : 0
                //};

                //DataLayer.DataEntity.LocationDetails location_Details = new DataLayer.DataEntity.LocationDetails
                //{
                //    //distance = locationDetails.distance,
                //    //restaurant_Name = locationDetails.restaurant_Name,
                //    xaxis = searchDetails.location.xaxis,
                //    yaxis = searchDetails.location.yaxis
                //};
                // DataLayer.DataEntity.SearchForRestautrant searchCritera = new DataLayer.DataEntity.SearchForRestautrant
                //{
                //    location = location_Details

                //};
                searched_Restaurant = search_Repository.GetRestaurantsBasedOnRatingOrder();
                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> 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;
     }
 }
Ejemplo n.º 12
0
        public static string getAverageOfLiquid(RestaurantInformation restaurantInformation)
        {
            ReadingFromFile <RestaurantInformation> listFile        = new ReadingFromFile <RestaurantInformation>();
            RestaurantInformationPecentageAverage   restaurant      = new RestaurantInformationPecentageAverage();
            List <RestaurantInformationAverage>     listRestaurants = restaurant.GetListWithPercentageAverage(listFile.Read());

            foreach (RestaurantInformationAverage restaurantsInformation in listRestaurants)
            {
                if (restaurantsInformation.Name.Equals(restaurantInformation.Name) && restaurantsInformation.Address.Equals(restaurantInformation.Address))
                {
                    return(restaurantsInformation.AverageOfPercentage.ToString());
                }
            }
            return("-");
        }
Ejemplo n.º 13
0
        public string GetAverageOfLiquid(RestaurantInformation restaurantInformation)
        {
            ReadingFromFileDeserialize <RestaurantInformation> restaurantListInFile          = new ReadingFromFileDeserialize <RestaurantInformation>();
            DistictRestaurantsWithAverageOfPercentage          distictRestaurantsWithAverage = new DistictRestaurantsWithAverageOfPercentage();
            List <RestaurantInformationAverage> restaurantsListWithAverage = distictRestaurantsWithAverage.GetListWithAverageOfPercentage(restaurantListInFile.Read(fileName: ConfigurationManager.AppSettings["FileName"]));

            foreach (RestaurantInformationAverage restaurantInformationAveraged in restaurantsListWithAverage)
            {
                if (restaurantInformationAveraged.Name.Equals(restaurantInformation.Name) && restaurantInformationAveraged.Address.Equals(restaurantInformation.Address))
                {
                    return(restaurantInformationAveraged.AverageOfPercentage.ToString());
                }
            }
            return("-");
        }
Ejemplo n.º 14
0
        public IQueryable <RestaurantInformation> SearchForRestaurant(SearchForRestaurant searchDetails)
        {
            List <RestaurantInformation> restaurant_Info = new List <RestaurantInformation>();

            try
            {
                DataLayer.DataEntity.SearchForRestautrant searchParms = new SearchForRestautrant()
                {
                    location = new DataLayer.DataEntity.LocationDetails()
                    {
                        distance = searchDetails.location.distance, xaxis = searchDetails.location.xaxis, yaxis = searchDetails.location.yaxis, restaurant_Name = searchDetails.location.restaurant_Name
                    },
                    search = new DataLayer.DataEntity.AddtitionalFeatureForSearch()
                    {
                        rating = searchDetails.search.rating, cuisine = searchDetails.search.cuisine, Menu = searchDetails.search.Menu
                    }
                };
                var searchResult = search_Repository.SearchForRestaurant(searchParms);
                if (searchResult != null)
                {
                    foreach (var restaurants in searchResult)
                    {
                        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,
                            Rating  = restaurants.Rating
                        };
                        restaurant_Info.Add(restaurant_Details);
                    }
                }

                return(restaurant_Info.AsQueryable());
            }
            catch (Exception ex)
            {
                return(restaurant_Info.AsQueryable());
            }
        }
Ejemplo n.º 15
0
        public async Task <bool> IsValidRestaurantAsync(AddToCartEntity cartEntity, int UserId, string UserToken)
        {
            using (HttpClient httpClient = WebAPIClient.GetClient(UserToken, UserId, _connectionStrings.Value.RestaurantApiUrl))
            {
                HttpResponseMessage httpResponseMessage = await httpClient.GetAsync("api/ResturantDetail?RestaurantID=" + cartEntity.RestaurantId);

                if (httpResponseMessage.IsSuccessStatusCode)
                {
                    string json = await httpResponseMessage.Content.ReadAsStringAsync();

                    RestaurantInformation restaurantInformation = JsonConvert.DeserializeObject <RestaurantInformation>(json);
                    if (restaurantInformation != null)
                    {
                        return(true);
                    }
                }
            }
            return(false);
        }
Ejemplo n.º 16
0
        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;
            }
        }
Ejemplo n.º 17
0
        public async Task <bool> IsOrderItemInStock(OrderEntity orderEntity, int UserId, string UserToken)
        {
            //using (HttpClient httpClient = WebAPIClient.GetClient(UserToken, UserId, _connectionStrings.Value.RestaurantApiUrl))
            using (HttpClient httpClient = new HttpClient())
            {
                HttpResponseMessage httpResponseMessage = await httpClient.GetAsync("http://localhost:10601/api/OrderDetail?RestaurantID=" + orderEntity.RestaurantId);

                if (httpResponseMessage.IsSuccessStatusCode)
                {
                    string json = await httpResponseMessage.Content.ReadAsStringAsync();

                    RestaurantInformation restaurantInformation = JsonConvert.DeserializeObject <RestaurantInformation>(json);
                    if (restaurantInformation != null)
                    {
                        return(true);
                    }
                }
            }
            return(false);
        }
        public IQueryable <RestaurantInformation> SearchRestaurantByLocation(BusinessEntities.LocationDetails locationDetails)
        {
            try
            {
                List <RestaurantInformation>         restaurant_Info = new List <RestaurantInformation>();
                IQueryable <RestaurantSearchDetails> searched_Restaurant;
                DataLayer.DataEntity.LocationDetails location_Details = new DataLayer.DataEntity.LocationDetails
                {
                    distance        = locationDetails.distance,
                    restaurant_Name = locationDetails.restaurant_Name,
                    xaxis           = locationDetails.xaxis,
                    yaxis           = locationDetails.yaxis
                };

                searched_Restaurant = search_Repository.GetRestaurantsBasedOnLocation(location_Details);
                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> SearchForRestaurantBasedOnMultipleFeactures(BusinessEntities.MultipleSearchFeature multiplesearchDetails)
 {
     try
     {
         List <RestaurantInformation>               restaurant_Info = new List <RestaurantInformation>();
         IQueryable <RestaurantSearchDetails>       searched_Restaurant;
         DataLayer.DataEntity.MultipleSearchFeature searchCritera = new DataLayer.DataEntity.MultipleSearchFeature
         {
             cuisine        = (string.IsNullOrEmpty(multiplesearchDetails.cuisine) ? "" : multiplesearchDetails.cuisine),
             Menu           = (string.IsNullOrEmpty(multiplesearchDetails.Menu) ? "" : multiplesearchDetails.Menu),
             rating         = (multiplesearchDetails.rating != null && multiplesearchDetails.rating > 0) ? multiplesearchDetails.rating : 0,
             RestaurantName = (string.IsNullOrEmpty(multiplesearchDetails.RestaurantName) ? "" : multiplesearchDetails.RestaurantName)
         };
         searched_Restaurant = search_Repository.SearchForRestaurantBasedOnMultipleFeactures(searchCritera);
         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;
     }
 }
Ejemplo n.º 20
0
        /// <summary>
        /// 跳转到餐厅信息页面
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void canting_Press(object sender, EventArgs e)
        {
            RestaurantInformation restaurantInformation = new RestaurantInformation();

            Show(restaurantInformation);
        }