Exemplo n.º 1
0
        public void Test_Find_FindsRestaurantInDatabase()
        {
            //Arrange
            Restaurant testRestaurant = new Restaurant("Red Lobster", "SW Funtime Lane", "503-555-5555", 3);

            testRestaurant.Save();

            //Act
            Restaurant foundRestaurant = Restaurant.Find(testRestaurant.getID());

            //Assert
            Assert.Equal(testRestaurant, foundRestaurant);
        }
Exemplo n.º 2
0
        public void Test_To_Assign_ID()
        {
            //Arrange, Act
            Restaurant restaurant = new Restaurant("Red Lobster", "SW Funtime Lane", "503-555-5555", 3);

            restaurant.Save();
            Restaurant savedRestaurant = Restaurant.GetAll()[0];

            int testID = restaurant.getID();
            int result = savedRestaurant.getID();

            //Assert
            Assert.Equal(testID, result);
        }
Exemplo n.º 3
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.getName() == newRestaurant.getName();
                bool       addressEquality     = this.getAddress() == newRestaurant.getAddress();
                bool       phoneNumberEquality = this.getPhoneNumber() == newRestaurant.getPhoneNumber();
                bool       cuisineIdEquality   = this.getCusineId() == newRestaurant.getCusineId();

                return(idEquality && nameEquality && addressEquality && phoneNumberEquality && cuisineIdEquality);
            }
        }
Exemplo n.º 4
0
        public HomeModule()
        {
            Get["/"] = _ => {
                return(View["index.cshtml"]);
            };

            Get["/cuisines"] = _ => {
                List <Cuisine> AllCuisines = Cuisine.GetAll();
                return(View["allCuisines.cshtml", AllCuisines]);
            };

            Get["cuisines/new"] = _ => {
                return(View["cuisine_form.cshtml"]);
            };

            Post["cuisines/new"] = _ => {
                Cuisine newCuisine = new Cuisine(Request.Form["cuisine-name"]);
                newCuisine.Save();
                return(View["success.cshtml"]);
            };

            Get["/restaurants/new"] = _ => {
                List <Cuisine> AllCuisines = Cuisine.GetAll();
                return(View["restaurant_form.cshtml", AllCuisines]);
            };

            Post["/restaurants/new"] = _ => {
                Restaurant newRestaurant = new Restaurant(Request.Form["name"], Request.Form["address"], Request.Form["phoneNumber"], Request.Form["cuisine-id"]);
                newRestaurant.Save();
                return(View["success.cshtml"]);
            };

            Get["/restaurants/delete"] = _ => {
                Restaurant.DeleteAll();
                return(View["success.cshtml"]);
            };

            Get["/cuisines/delete"] = _ => {
                Cuisine.DeleteAll();
                return(View["success.cshtml"]);
            };

            Get["/cuisines/{id}"] = parameters => {
                Dictionary <string, object> model = new Dictionary <string, object>();
                var SelectedCuisine    = Cuisine.Find(parameters.id);
                var CuisineRestaurants = SelectedCuisine.GetRestaurants();
                // var RestaurantReviews =
                model.Add("cuisine", SelectedCuisine);
                model.Add("restaurants", CuisineRestaurants);
                return(View["cuisine.cshtml", model]);
            };

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

            Patch["/cuisine/edit/{id}"] = parameters => {
                Cuisine SelectedCuisine = Cuisine.Find(parameters.id);
                SelectedCuisine.Update(Request.Form["cuisine-name"]);
                return(View["success.cshtml"]);
            };

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

            Delete["/cuisine/delete/{id}"] = parameters => {
                Cuisine SelectedCuisine = Cuisine.Find(parameters.id);
                SelectedCuisine.Delete();
                return(View["success.cshtml"]);
            };
            Get["/restaurants/edit/{id}"] = parameters => {
                Restaurant SelectedRestaurant = Restaurant.Find(parameters.id);
                return(View["restaurant_edit.cshtml", SelectedRestaurant]);
            };
            Patch["/restaurants/edit/{id}"] = parameters => {
                Restaurant SelectedRestaurant = Restaurant.Find(parameters.id);
                SelectedRestaurant.UpdateName(Request.Form["edit"]);
                return(View["success.cshtml"]);
            };

            Get["/restaurant/delete/{id}"] = parameters => {
                Restaurant SelectedRestaurant = Restaurant.Find(parameters.id);
                return(View["restaurant_delete.cshtml", SelectedRestaurant]);
            };

            Delete["/restaurant/delete/{id}"] = parameters => {
                Restaurant SelectedRestaurant = Restaurant.Find(parameters.id);
                SelectedRestaurant.Delete();
                return(View["success.cshtml"]);
            };

            Get["/restaurant/{id}/reviews"] = parameters => {
                Restaurant SelectedRestaurant = Restaurant.Find(parameters.id);
                return(View["review_form.cshtml", SelectedRestaurant]);
            };

            Post["/restaurant/{id}/reviews"] = parameters => {
                Restaurant SelectedRestaurant = Restaurant.Find(parameters.id);
                int        id        = SelectedRestaurant.getID();
                Review     newReview = new Review(Request.Form["reviewNumber"], id);
                newReview.Save();
                return(View["success.cshtml"]);
            };
        }