예제 #1
0
 public override bool Equals(System.Object otherRestaurant)
 {
     if (!(otherRestaurant is Restaurant))
     {
         return(false);
     }
     else
     {
         Restaurant newRestaurant               = (Restaurant)otherRestaurant;
         bool       restaurantIdEquality        = (this.GetId() == newRestaurant.GetId());
         bool       restaurantNameEquality      = (this.GetName() == newRestaurant.GetName());
         bool       restaurantCuisineIdEquality = (this.GetCuisineId() == newRestaurant.GetCuisineId());
         return(restaurantNameEquality && restaurantCuisineIdEquality && restaurantIdEquality);
     }
 }
예제 #2
0
 public override bool Equals(System.Object otherRestaurant)
 {
     if (!(otherRestaurant is Restaurant))
     {
         return(false);
     }
     else
     {
         Restaurant newRestaurant       = (Restaurant)otherRestaurant;
         bool       idEquality          = (this.GetId() == newRestaurant.GetId());
         bool       descriptionEquality = (this.GetDescription() == newRestaurant.GetDescription());
         bool       cuisineEquality     = this.GetCuisineId() == newRestaurant.GetCuisineId();
         bool       addressEquality     = this.GetAddress() == newRestaurant.GetAddress();
         return(idEquality && descriptionEquality && cuisineEquality && addressEquality);
     }
 }
예제 #3
0
 public override bool Equals(System.Object otherRestaurant)
 {
     if (!(otherRestaurant is Restaurant))
     {
         return(false);
     }
     else
     {
         Restaurant newRestaurant  = (Restaurant)otherRestaurant;
         bool       nameEquals     = this.GetName() == newRestaurant.GetName();
         bool       idEquals       = this.GetCuisineId() == newRestaurant.GetCuisineId();
         bool       dateEquals     = this.GetDateTime() == newRestaurant.GetDateTime();
         bool       locationEquals = this.GetLocation() == newRestaurant.GetLocation();
         return(nameEquals && idEquals && dateEquals && locationEquals);
     }
 }
예제 #4
0
        public override bool Equals(System.Object otherRestaurant)
        {
            if (!(otherRestaurant is Restaurant))
            {
                return(false);
            }
            else
            {
                Restaurant newRestaurant     = (Restaurant)otherRestaurant;
                bool       idEquality        = (this.GetId() == newRestaurant.GetId());
                bool       nameEquality      = (this.GetRestaurantName() == newRestaurant.GetRestaurantName());
                bool       cuisineIdEquality = (this.GetCuisineId() == newRestaurant.GetCuisineId());
                bool       addressEquality   = (this.GetAddress() == newRestaurant.GetAddress());
                bool       openTimeEquality  = (this.GetOpenTime() == newRestaurant.GetOpenTime());
                bool       closeTimeEquality = (this.GetCloseTime() == newRestaurant.GetCloseTime());

                return(idEquality && nameEquality && cuisineIdEquality && addressEquality && openTimeEquality && closeTimeEquality);
            }
        }
        public void Test_Update_RestaurantInDataBase()
        {
            string     originalRestaurantName    = "bob's mexican";
            int        originalRestaurantCuisine = 1;
            Restaurant originalRestaurant        = new Restaurant(originalRestaurantName, originalRestaurantCuisine);

            originalRestaurant.Save();
            string     newRestaurantName    = "Bob's sushi";
            int        newRestaurantCuisine = 2;
            Restaurant updatedRestaurant    = new Restaurant(newRestaurantName, newRestaurantCuisine);

            originalRestaurant.Update(newRestaurantName, newRestaurantCuisine);
            Console.WriteLine(originalRestaurant.GetId());
            Console.WriteLine(originalRestaurant.GetName());
            Console.WriteLine(originalRestaurant.GetCuisineId());

            Restaurant foundRestaurant = Restaurant.Find(originalRestaurant.GetId());

            Console.WriteLine(foundRestaurant.GetId());
            Console.WriteLine(foundRestaurant.GetName());
            Console.WriteLine(foundRestaurant.GetCuisineId());
            Assert.Equal(foundRestaurant, originalRestaurant);
        }
예제 #6
0
        public HomeModule()
        {
            Get["/"] = _ => {
                List <Cuisine> allCuisines = Cuisine.GetAll();
                return(View["index.cshtml", allCuisines]);
            };

            Post["/cuisine/new"] = _ => {
                string  newCuisineName = Request.Form["cuisine-name"];
                Cuisine newCuisine     = new Cuisine(newCuisineName);
                newCuisine.Save();
                List <Cuisine> allCuisines = Cuisine.GetAll();
                return(View["index.cshtml", allCuisines]);
            };

            Get["/cuisines/{id}"] = parameters => {
                Cuisine currentCuisine = Cuisine.Find(parameters.id);
                return(View["cuisine.cshtml", currentCuisine]);
            };

            Get["/cuisines/delete/{id}"] = parameters => {
                Cuisine currentCuisine = Cuisine.Find(parameters.id);
                return(View["cuisine_delete.cshtml", currentCuisine]);
            };

            Delete["/cuisines/delete/{id}"] = parameters => {
                Cuisine currentCuisine = Cuisine.Find(parameters.id);
                currentCuisine.DeleteCuisine();
                List <Cuisine> allCuisines = Cuisine.GetAll();
                return(View["index.cshtml", allCuisines]);
            };

            Get["/cuisines/update/{id}"] = parameters => {
                Cuisine currentCuisine = Cuisine.Find(parameters.id);
                return(View["cuisine_update.cshtml", currentCuisine]);
            };

            Patch["/cuisines/update/{id}"] = parameters => {
                Cuisine currentCuisine = Cuisine.Find(parameters.id);
                currentCuisine.Update(Request.Form["cuisine-name"]);
                return(View ["cuisine.cshtml", currentCuisine]);
            };

            Get["/cuisines/{id}/restaurants/new"] = parameters => {
                Cuisine currentCuisine = Cuisine.Find(parameters.id);
                return(View["restaurant_form.cshtml", currentCuisine]);
            };

            Post["/cuisines/{id}/restaurants/new"] = parameters => {
                Restaurant newRestaurant = new Restaurant(Request.Form["restaurant-name"], parameters.id, Request.Form["restaurant-address"], Request.Form["restaurant-open-time"], Request.Form["restaurant-close-time"]);
                newRestaurant.Save();
                return(View["cuisine.cshtml", Cuisine.Find(parameters.id)]);
            };

            Get["/cuisines/{cuisineId}/restaurants/{id}"] = parameters => {
                Restaurant currentRestaurant      = Restaurant.Find(parameters.id);
                Cuisine    currentCuisine         = Cuisine.Find(parameters.cuisineId);
                Dictionary <string, object> model = new Dictionary <string, object>()
                {
                    { "restaurant", currentRestaurant }, { "cuisine", currentCuisine }
                };
                return(View["restaurant_info.cshtml", model]);
            };

            Get["/cuisines/{cuisineId}/restaurants/{id}/delete"] = parameters => {
                Restaurant currentRestaurant      = Restaurant.Find(parameters.id);
                Cuisine    currentCuisine         = Cuisine.Find(parameters.cuisineId);
                Dictionary <string, object> model = new Dictionary <string, object>()
                {
                    { "restaurant", currentRestaurant }, { "cuisine", currentCuisine }
                };
                return(View["restaurant_delete.cshtml", model]);
            };

            Delete["/cuisines/{cuisineId}/restaurants/{id}/delete"] = parameters => {
                Restaurant currentRestaurant = Restaurant.Find(parameters.id);
                Cuisine    currentCuisine    = Cuisine.Find(parameters.cuisineId);
                currentRestaurant.DeleteRestaurant();
                // List<Restaurant> CuisineRestaurants = currentCuisine.GetRestaurants();
                return(View["cuisine.cshtml", currentCuisine]);
            };

            Get["/cuisines/{cuisineId}/restaurants/{id}/update"] = parameters => {
                Restaurant     currentRestaurant  = Restaurant.Find(parameters.id);
                List <Cuisine> allCuisines        = Cuisine.GetAll();
                Dictionary <string, object> model = new Dictionary <string, object>()
                {
                    { "restaurant", currentRestaurant }, { "cuisines", allCuisines }
                };
                return(View["restaurant_update.cshtml", model]);
            };

            Patch["/cuisines/{cuisineId}/restaurants/{id}/update"] = parameters => {
                Restaurant currentRestaurant = Restaurant.Find(parameters.id);
                currentRestaurant.Update(Request.Form["restaurant-name"], Request.Form["cuisine-name"], Request.Form["restaurant-address"], Request.Form["restaurant-open-time"], Request.Form["restaurant-close-time"]);
                Cuisine currentCuisine            = Cuisine.Find(currentRestaurant.GetCuisineId());
                Dictionary <string, object> model = new Dictionary <string, object> {
                    { "restaurant", currentRestaurant }, { "cuisine", currentCuisine }
                };
                return(View["restaurant_info.cshtml", model]);
            };
        }