예제 #1
0
 public ActionResult Create(Restaurant newRestaurant)
 {
     try
     {
         _restaurantBL.AddRestaurant(newRestaurant);
         return(RedirectToAction(nameof(Index)));
     }
     catch
     {
         return(View());
     }
 }
예제 #2
0
        private void AddRestaurant()
        {
            Console.WriteLine("Please enter the restaurant details of the restaurant you want to add");
            string name  = _validation.ValidString("Name: ");
            string city  = _validation.ValidString("City: ");
            string state = _validation.ValidString("State: ");

            try
            {
                Restaurant newRestaurant = _restaurantBL.AddRestaurant(new Restaurant(name, city, state));
                Console.WriteLine("Restaurant added!");
                Console.WriteLine(newRestaurant.ToString());
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                AddRestaurant();
            }
        }