internal static void Find()
        {
            string option;

            Console.Write("Search for restaurant by full or parital name: ");
            string Search = Console.ReadLine();

            RestaurantAccessLibrary.ReturnGetRestaurantFullName(Search);
            if (RestaurantAccessLibrary.GetRestaurantFullName(Search).Item1 == null)
            {
                Console.WriteLine();
                Console.WriteLine("Make sure search is a name, or try shortening the search");
                Find();
            }
            Console.WriteLine();
            Console.WriteLine("What would you like to do?");
            Console.WriteLine("Type 'select' and then Restaurant name to select it ");
            Console.WriteLine("Type 'back' to go back");
            option = Console.ReadLine();
            if (option.Length > 6)
            {
                if (option.Substring(0, 6).Equals("select"))
                {
                    Select(option.Substring(7, option.Length - 7));
                }
            }
        }
Ejemplo n.º 2
0
        internal static void AddReview(RestaurantModels.Restaurant restaurant)
        {
            while (true)
            {
                Console.WriteLine();
                Console.WriteLine("Type 'add' to add review to restaurant");
                Console.WriteLine("Type 'get' to see all reviews for restaurant");
                Console.WriteLine("Type 'avg' to get average review");
                Console.WriteLine("Type 'info' for restaurant info");
                Console.WriteLine("Type 'back' to go back");
                Console.WriteLine("Type 'exit' to exit");
                string option = Console.ReadLine();
                switch (option)
                {
                case "add":
                    RestaurantAccessLibrary.AddNewReview(RestaurantModels.Restaurant.CreateReview(restaurant));
                    break;

                case "back":
                    Find();
                    break;

                case "get":
                    foreach (var item in RestaurantAccessLibrary.GetRestaurantByID(restaurant.ID).Reviews)
                    {
                        Console.WriteLine(item.GetFormattedReview());
                    }
                    break;

                case "avg":
                    Console.WriteLine();
                    Console.WriteLine("Average Review Rating: " + restaurant.GetAvgReview());
                    break;

                case "info":
                    Console.WriteLine();
                    restaurant.PrintInfo();
                    break;

                case "exit":
                    Exit();
                    break;

                default:
                    Console.WriteLine("Enter Valid Option");
                    log.Error($"{option} is not a valid option");
                    break;
                }
            }
        }
 internal static void Select(string selected)
 {
     Console.WriteLine();
     Console.WriteLine("Selected: " + selected);
     RestaurantModels.Restaurant restaurant = RestaurantAccessLibrary.GetRestaurantByName(selected);
     if (restaurant == null)
     {
         Console.WriteLine();
         Console.WriteLine("Please enter correct restaurant name");
         Find();
     }
     else
     {
         AddReview(restaurant);
     }
 }
Ejemplo n.º 4
0
 internal static void Select(string selected)
 {
     Console.WriteLine("Selected: " + selected);
     try
     {
         RestaurantModels.Restaurant restaurant = RestaurantAccessLibrary.GetRestaurantByName(selected);
         AddReview(restaurant);
     }
     catch (Exception e)
     {
         log.Error($"{selected} cannot be converted or does not exist");
         Console.WriteLine();
         Console.WriteLine("Please enter correct restaurant name");
         Find();
     }
 }
 public ActionResult Edit(int id, Review review)
 {
     if (!ModelState.IsValid)
     {
         log.Error($"{review} is not valid");
         return(View(review));
     }
     try
     {
         RestaurantAccessLibrary.EditReview(id, review);
         return(RedirectToAction("Search", "Search", null));
     }
     catch (Exception e)
     {
         log.Error($"Exception, {e}");
         return(View());
     }
 }
 public ActionResult Delete(int id, FormCollection collection)
 {
     if (!ModelState.IsValid)
     {
         log.Error($"is not valid");
         return(View(id));
     }
     try
     {
         Review rev = RestaurantAccessLibrary.GetReviewByID(id);
         RestaurantAccessLibrary.DeleteReview(rev);
         return(RedirectToAction("Search", "Search"));
     }
     catch (Exception e)
     {
         log.Error($"Exception, {e}");
         return(View());
     }
 }
 public ActionResult Edit(int id, Restaurant restaurant)
 {
     if (!ModelState.IsValid)
     {
         log.Error($"{restaurant} is not a valid model");
         return(View(restaurant));
     }
     try
     {
         // TODO: Add update logic here
         RestaurantAccessLibrary.EditRestaurant(id, restaurant);
         return(RedirectToAction("Index"));
     }
     catch (Exception e)
     {
         log.Error($"Exception, {e}");
         return(View());
     }
 }
 public ActionResult Create(Restaurant restaurant)
 {
     if (!ModelState.IsValid)
     {
         log.Error($"{restaurant} is not a valid model");
         return(View(restaurant));
     }
     try
     {
         // TODO: Add insert logic here
         RestaurantAccessLibrary.AddNewRestaurnt(restaurant);
         return(RedirectToAction("Index"));
     }
     catch (Exception e)
     {
         log.Error($"Exception, {e}");
         return(View());
     }
 }
 public ActionResult DeleteConfirmed(int id)
 {
     if (!ModelState.IsValid)
     {
         log.Error($"{RestaurantAccessLibrary.GetRestaurantByID(id)} is not a valid model");
         return(View(id));
     }
     try
     {
         // TODO: Add delete logic here
         Restaurant rest = RestaurantAccessLibrary.GetRestaurantByID(id);
         RestaurantAccessLibrary.DeleteRestaurant(rest);
         return(RedirectToAction("Index"));
     }
     catch (Exception e)
     {
         log.Error($"Exception, {e}");
         return(View());
     }
 }
        static void Main(string[] args)
        {
Start:
            Console.WriteLine();
            Console.WriteLine("What would you like to do?: ");
            Console.WriteLine("Type 'find' to find restaurant");
            Console.WriteLine("Type 'top' to list top 3 best reviewed restauratns");
            Console.WriteLine("Type 'all review' to list all resturants in order of rating");
            Console.WriteLine("Type 'all city asc' to list all restauratns in order of city ascending");
            Console.WriteLine("Type 'all city desc' to list all restauratns in order of city descending");
            Console.WriteLine("Type 'all name asc' to list all restauratns in order of name ascending");
            Console.WriteLine("Type 'all name desc' to list all restauratns in order of name descending");
            Console.WriteLine("Type 'exit' to exit");
            Console.WriteLine();
            while (true)
            {
                IEnumerable <Restaurant> top;
                IEnumerable <RReviews.DAL.Restaurant> top2;
                string option = Console.ReadLine();
                switch (option)
                {
                case "find":
                    Console.WriteLine();
                    Running.Find();
                    break;

                case "exit":
                    Running.Exit();
                    break;

                case "top":
                    Console.WriteLine();
                    top2 = RestaurantAccessLibrary.GetBestReviewedRestaurantsTop3();
                    foreach (var item in top2)
                    {
                        Console.WriteLine("Restaurant Name: " + item.Name + ", Rating: " + item.getAvgReview());
                    }
                    goto Start;

                case "all review":
                    Console.WriteLine();
                    top2 = RestaurantAccessLibrary.GetAllRestaurantsByReviewDescending();
                    foreach (var item in top2)
                    {
                        Console.WriteLine("Restaurant Name: " + item.Name + ", Rating: " + item.getAvgReview());
                    }
                    goto Start;

                case "all name asc":
                    Console.WriteLine();
                    top = RestaurantAccessLibrary.GetRestaurantsByNameAscending();
                    foreach (var item in top)
                    {
                        Console.WriteLine("Restaurant Name: " + item.Name + ", Rating: " + item.GetAvgReview());
                    }
                    goto Start;

                case "all name desc":
                    Console.WriteLine();
                    top = RestaurantAccessLibrary.GetRestaurantsByNameDescending();
                    foreach (var item in top)
                    {
                        Console.WriteLine("Restaurant Name: " + item.Name + ", Rating: " + item.GetAvgReview());
                    }
                    goto Start;

                case "all city asc":
                    Console.WriteLine();
                    top = RestaurantAccessLibrary.GetRestaurantsByLocationCityAscending();
                    foreach (var item in top)
                    {
                        Console.WriteLine("Restaurant location: " + item.GetLocation() + ", Restaurant Name: " + item.Name + ", Rating: " + item.GetAvgReview());
                    }
                    goto Start;

                case "all city desc":
                    Console.WriteLine();
                    top = RestaurantAccessLibrary.GetRestaurantsByLocationCityDescending();
                    foreach (var item in top)
                    {
                        Console.WriteLine("Restaurant location: " + item.GetLocation() + ", Restaurant Name: " + item.Name + ", Rating: " + item.GetAvgReview());
                    }
                    goto Start;

                default:
                    Console.WriteLine("Enter Valid Option");
                    Console.WriteLine();
                    goto Start;
                }
            }
        }
 // GET: Review/Delete/5
 public ActionResult Delete(int id)
 {
     return(View(RestaurantAccessLibrary.GetReviewByID(id)));
 }
 // GET: Review/Details/5
 public ActionResult Details(int id)
 {
     return(View(RestaurantAccessLibrary.GetRestaurantByID(id).Reviews));
 }
 // GET: Restaurant/Edit/5
 public ActionResult Edit(int id)
 {
     return(View(RestaurantAccessLibrary.GetRestaurantByID(id)));
 }
 // GET: Restaurant
 public ActionResult Index()
 {
     return(View(RestaurantAccessLibrary.GetRestaurantsByNameAscending()));
 }