public static IEnumerable <RestaurantComp.Restaurant> GetDataRestaurants() { Crud <RestaurantDataAccessLayer.Restaurant> crud = new Crud <Restaurant>(); List <RestaurantComp.Restaurant> returnList = new List <RestaurantComp.Restaurant>(); foreach (RestaurantDataAccessLayer.Restaurant x in crud.ToList()) { returnList.Add(LibraryConverter.RestDataToLibConversion(x)); } return(returnList); }
public void TestDataToLibConversion() { //arrange LibraryConverter converter = new LibraryConverter(); //act System.Collections.Generic.List <RestaurantComp.Restaurant> list = converter.DataToLibConversion(); //assert Assert.AreEqual(list[0].name.ToLower(), "Willies".ToLower()); Assert.AreEqual(list[0].cuisine.ToLower(), "Sports Bar".ToLower()); Assert.AreEqual(list[0].reviews[0].rating, 4.6); //Assert.AreEqual(list[0].reviews[1].rating, 4.2); }
public static IEnumerable <RestaurantComp.Restaurant> GetTop3() { Crud <RestaurantDataAccessLayer.Restaurant> crud = new Crud <Restaurant>(); List <RestaurantComp.Restaurant> returnList = new List <RestaurantComp.Restaurant>(); foreach (RestaurantDataAccessLayer.Restaurant x in crud.ToList()) { returnList.Add(LibraryConverter.RestDataToLibConversion(x)); } returnList.Sort(new BestToWorstSorter()); if (returnList.Count >= 3) { return(returnList.GetRange(0, 3)); } else { return(returnList); } }
static void Main(string[] args) { List <RestaurantComp.Restaurant> restaurants = new LibraryConverter().DataToLibConversion(); restaurants.Sort(new BestToWorstSorter()); foreach (Restaurant x in restaurants) { Console.WriteLine("Restaurant Name: {0} Cuisine: {1}", x.name, x.cuisine); } Console.WriteLine("*******************"); Console.Write("The Three Best are "); for (int i = 0; i < 3; i++) { if (i <= restaurants.Count - 1) { Console.WriteLine("Restaurant Name: {0} Cuisine: {1}", restaurants[i].name, restaurants[i].cuisine); } } foreach (Restaurant x in restaurants) { x.PrintReviews(); } Console.WriteLine("Search for Restaurant here"); string searchString = Console.ReadLine(); foreach (Restaurant x in restaurants) { if (x.name.Contains(searchString)) { Console.WriteLine("************"); Console.WriteLine("Restaurant Found! {0} Cuisine {1}", x.name, x.cuisine); } else { Console.WriteLine("Searching"); } } }
public static void AddReview(Reviews.Review rev) { Crud <RestaurantDataAccessLayer.Review> crud = new Crud <RestaurantDataAccessLayer.Review>(); crud.Add(LibraryConverter.RevLibToDataConverion(rev)); }