Example #1
0
        public ICollection <Restaurant> convertList(List <RestaurantReviewsData.Restaurant> tempList)
        {
            List <Restaurant> result = (List <Restaurant>)LibHelper.DataListToLibraryList(tempList);

            return(result);
        }
Example #2
0
        public bool OptionHandler()
        {
            int selection;
            ICollection <Restaurant> list;

            Console.WriteLine("");
            selection = SelectOption();
            List <Restaurant> convertedList = (List <RestaurantReviewsLibrary.Restaurant>)sort.convertList((List <RestaurantReviewsData.Restaurant>)crud.ListRestaurants());

            if (selection == 1)
            {
                list = sort.SortByRating(3, convertedList);
                foreach (Restaurant rest in list)
                {
                    Console.WriteLine(rest.RestaurantName + ": " + rest.CustomerRating);
                }
                return(false);
            }
            if (selection == 2)
            {
                int sortDecision = 0;
                while (sortDecision != 1 && sortDecision != 2)
                {
                    Console.WriteLine("");
                    Console.WriteLine("To sort by name please enter 1.");
                    Console.WriteLine("To sort by rating please enter 2.");
                    sortDecision = int.Parse(Console.ReadLine());
                }
                if (sortDecision == 1)
                {
                    Console.WriteLine("");
                    list = sort.SortByNameAscending(convertedList);
                    foreach (Restaurant rest in list)
                    {
                        Console.WriteLine(rest.RestaurantName);
                    }
                    return(false);
                }
                if (sortDecision == 2)
                {
                    list = sort.SortByRating(convertedList);
                    Console.WriteLine("");
                    foreach (Restaurant rest in list)
                    {
                        Console.WriteLine(rest.RestaurantName + ": " + rest.CustomerRating);
                    }
                    return(false);
                }
            }
            if (selection == 3)
            {
                Console.WriteLine("");
                int idDecision;
                Console.WriteLine("Enter a restaurant Id:");
                idDecision = int.Parse(Console.ReadLine());
                crud.ReadRestaurantDetails(idDecision);
                return(false);
            }
            if (selection == 4)
            {
                Console.WriteLine("");
                ICollection <Review> revList;
                int idDecision;
                Console.WriteLine("Enter a restaurant Id:");
                idDecision = int.Parse(Console.ReadLine());
                revList    = LibHelper.DataReviewListToLibraryReviewList(crud.GetReviewsById(idDecision));
                foreach (Review rev in revList)
                {
                    Console.WriteLine("Reivewer name: " + rev.ReviewerName + ": " + rev.ReviewText + " Score: " + rev.ReviewScore);
                }
                return(false);
            }
            if (selection == 5)
            {
                Console.WriteLine("");
                string searchQuery;
                Console.WriteLine("Search for: ");
                searchQuery = Console.ReadLine();
                list        = sort.SearchRestaurantByName(searchQuery, convertedList);
                foreach (Restaurant res in list)
                {
                    Console.WriteLine(res.RestaurantName);
                }
                return(false);
            }
            if (selection == 6)
            {
                return(true);
            }
            return(false);
        }