public void Test_Delete_DeleteCuisineFromDatabase() { //Arrange string name1 = "Gary"; Cuisine testCategory1 = new Cuisine(name1, "menu1"); testCategory1.Save(); string name2 = "Wallace"; Cuisine testCategory2 = new Cuisine(name2, "menu2"); testCategory2.Save(); Restaurant testaurant = new Restaurant("Shoney's", "fastfood", testCategory1.GetId()); testaurant.Save(); Restaurant testaurant1 = new Restaurant("Steven Luicci", "trap house", testCategory2.GetId()); testaurant1.Save(); //Act testCategory1.Delete(); List <Cuisine> resultCuisine = Cuisine.GetAll(); List <Cuisine> testCuisine = new List <Cuisine> { testCategory2 }; List <Restaurant> resultRestaurants = Restaurant.GetAll(); List <Restaurant> testaurantList = new List <Restaurant> { testaurant1 }; //Assert Assert.Equal(testCuisine, resultCuisine); Assert.Equal(testaurantList, resultRestaurants); }
public void Test_FindRestaurantInDatabase() { Restaurant testRestaurant = new Restaurant("j", "3", 1); testRestaurant.Save(); Restaurant foundRestaurant = Restaurant.Find(testRestaurant.GetId()); Assert.Equal(testRestaurant, foundRestaurant); }
public void Test_Save_ToRestaurantDatabase() { Restaurant testRestaurant = new Restaurant("Grandma's House", "Vancouver", 1); testRestaurant.Save(); List <Restaurant> result = Restaurant.GetAll(); List <Restaurant> testList = new List <Restaurant> { testRestaurant }; Assert.Equal(testList, result); }
public void Test_Find_FindRestaurantInDatabase() { //Arrange Restaurant testRestaurant = new Restaurant("Shoney's", "American", 1); testRestaurant.Save(); //Act Restaurant foundRestaurant = Restaurant.Find(testRestaurant.GetId()); //Assert Assert.Equal(testRestaurant, foundRestaurant); }
public void Test_Save_SavesToDatabase() { //Arrange Restaurant testRestaurant = new Restaurant("Shoney", "American", 1); //Act testRestaurant.Save(); List <Restaurant> result = Restaurant.GetAll(); List <Restaurant> testList = new List <Restaurant> { testRestaurant }; //Assert Assert.Equal(testList, result); }
public void Test_Update_UpdatesRestaurantInDatabase() { //Arrange string style = "Cafe, baby"; string name = "Baby Cafe"; Restaurant testaurant = new Restaurant(name, style, 1); testaurant.Save(); string newStyle = "Fine Dining"; string newName = "Dine Fining"; //Act testaurant.Update("Fine Dining", "Dine Fining"); string result = testaurant.GetStyle(); //Assert Assert.Equal(newStyle, result); }
public void Test_GetRestaurants_RetrievesAllRestaurantsWithCuisine() { Cuisine testCuisine = new Cuisine("Moroccan", "Rasins and nuts and shit oh and tumeric"); testCuisine.Save(); Restaurant firstRestaurant = new Restaurant("Lemur", "a location", testCuisine.GetId()); firstRestaurant.Save(); Restaurant secondRestaurant = new Restaurant("Aye-Aye", "another location", testCuisine.GetId()); secondRestaurant.Save(); List <Restaurant> testRestaurantList = new List <Restaurant> { firstRestaurant, secondRestaurant }; List <Restaurant> resultRestaurantList = testCuisine.GetRestaurants(); Assert.Equal(testRestaurantList, resultRestaurantList); }
public void Test_Delete_DeleteRestaurantFromDatabase() { //Arrange Restaurant testRestaurant1 = new Restaurant("Shoney's", "fastfood", 1); testRestaurant1.Save(); Restaurant testRestaurant2 = new Restaurant("Luis's", "fastfood", 2); testRestaurant2.Save(); //Act testRestaurant1.Delete(); List <Restaurant> resultRestaurants = Restaurant.GetAll(); List <Restaurant> testRestaurant = new List <Restaurant> { testRestaurant2 }; //Assert Assert.Equal(resultRestaurants, testRestaurant); }
public void Test_Delete_DeletesCuisineFromDatabase() { //Arrange string type1 = "French"; string description1 = "BOULLIABAISE"; Cuisine testCuisine1 = new Cuisine(type1, description1); testCuisine1.Save(); string type2 = "German"; string description2 = "WEINERSHNITZLE"; Cuisine testCuisine2 = new Cuisine(type2, description2); testCuisine2.Save(); Restaurant testRestaurant1 = new Restaurant("Le Gummy Bears", "location1", testCuisine1.GetId()); testRestaurant1.Save(); Restaurant testRestaurant2 = new Restaurant("Nein Germans", "location2", testCuisine2.GetId()); testRestaurant2.Save(); //Act testCuisine1.Delete(); List <Cuisine> resultCuisines = Cuisine.GetAll(); List <Cuisine> testCuisineList = new List <Cuisine> { testCuisine2 }; List <Restaurant> resultRestaurants = Restaurant.GetAll(); List <Restaurant> testRestaurantList = new List <Restaurant> { testRestaurant2 }; //Assert Assert.Equal(testCuisineList, resultCuisines); Assert.Equal(testRestaurantList, resultRestaurants); }
public void Test_GetRestaurants_RetrieveAllRestaurantsWithinCuisine() { //Arrange Cuisine testCuisine = new Cuisine("Italian", "pizza"); testCuisine.Save(); Restaurant firstRestaurant = new Restaurant("Shoney's", "American", testCuisine.GetId()); firstRestaurant.Save(); Restaurant secondRestaurant = new Restaurant("Luis's", "Italian", testCuisine.GetId()); secondRestaurant.Save(); //Act List <Restaurant> testRestaurantList = new List <Restaurant> { firstRestaurant, secondRestaurant }; List <Restaurant> resultRestaurantList = testCuisine.GetRestaurants(); //Assert Assert.Equal(testRestaurantList, resultRestaurantList); }
public HomeModule() { Get["/"] = _ => { return(View["index.cshtml"]); }; Get["/cuisines"] = _ => { List <Cuisine> allCuisines = Cuisine.GetAll(); return(View["cuisines.cshtml", allCuisines]); }; Get["/cuisines/new"] = _ => { return(View["cuisine_add.cshtml"]); }; Post["/cuisines/new"] = _ => { Cuisine newCuisine = new Cuisine(Request.Form["cuisine-type"], Request.Form["cuisine-description"]); newCuisine.Save(); return(View["success.cshtml"]); }; Get["/restaurants"] = _ => { List <Restaurant> allRestaurants = Restaurant.GetAll(); return(View["restaurants.cshtml", allRestaurants]); }; Get["/restaurants/new"] = _ => { List <Cuisine> allCuisines = Cuisine.GetAll(); return(View["restaurant_add.cshtml", allCuisines]); }; Post["/restaurants/new"] = _ => { Restaurant newRestaurant = new Restaurant(Request.Form["restaurant-name"], Request.Form["restaurant-location"], Request.Form["cuisine-id"]); newRestaurant.Save(); return(View["success.cshtml"]); }; Get["/restaurants/new_review"] = _ => { List <Restaurant> allRestaurants = Restaurant.GetAll(); return(View["review_add.cshtml", allRestaurants]); }; Post["/reviews/new"] = _ => { Review newReview = new Review(Request.Form["review-UserName"], Request.Form["review-score"], Request.Form["review-comment"], Request.Form["restaurant-id"]); newReview.Save(); 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(); model.Add("cuisine", selectedCuisine); model.Add("restaurants", cuisineRestaurants); return(View["cuisine.cshtml", model]); }; Get["/restaurants/{id}"] = parameters => { Dictionary <string, object> model = new Dictionary <string, object>(); var selectedRestaurant = Restaurant.Find(parameters.id); var restaurantReviews = selectedRestaurant.GetReviews(); var restaurantAvgReviews = Review.GetRestaurantAverage(parameters.id); model.Add("restaurant", selectedRestaurant); model.Add("reviews", restaurantReviews); model.Add("average", restaurantAvgReviews); return(View["restaurant.cshtml", model]); }; Get["cuisines/{id}/edit"] = parameters => { Dictionary <string, object> model = new Dictionary <string, object>(); Cuisine selectedCuisine = Cuisine.Find(parameters.id); model.Add("selectedCuisine", selectedCuisine); return(View["cuisine_edit.cshtml", model]); }; Patch["/cuisines/{id}/edit"] = parameters => { Cuisine selectedCuisine = Cuisine.Find(parameters.id); string newType = Request.Form["cuisine-type"]; string newDescription = Request.Form["cuisine-description"]; if (newType == "" && newDescription != "") { selectedCuisine.UpdateDescription(newDescription); } else if (newType != "" && newDescription == "") { selectedCuisine.UpdateType(newType); } else { selectedCuisine.UpdateDescription(newDescription); selectedCuisine.UpdateType(newType); } return(View["success.cshtml"]); }; Get["restaurants/{id}/delete"] = parameters => { Restaurant selectedRestaurant = Restaurant.Find(parameters.id); return(View["restaurant_delete.cshtml", selectedRestaurant]); }; Delete["restaurants/{id}/delete"] = parameters => { Restaurant selectedRestaurant = Restaurant.Find(parameters.id); selectedRestaurant.Delete(); return(View["success.cshtml"]); }; }
public HomeModule() { Get["/"] = _ => { return(View["index.cshtml"]); }; Get["/cuisines"] = _ => { List <Cuisine> allCuisines = Cuisine.GetAll(); return(View["cuisines.cshtml", allCuisines]); }; Get["/cuisines/new"] = _ => { return(View["cuisine_add.cshtml"]); }; Post["/cuisines/new"] = _ => { Cuisine newCuisine = new Cuisine(Request.Form["cuisine-type"], Request.Form["cuisine-description"]); newCuisine.Save(); return(View["success.cshtml"]); }; Get["/restaurants"] = _ => { List <Restaurant> allRestaurants = Restaurant.GetAll(); return(View["restaurants.cshtml", allRestaurants]); }; Get["/restaurants/new"] = _ => { List <Cuisine> allCuisines = Cuisine.GetAll(); return(View["restaurant_add.cshtml", allCuisines]); }; Post["/restaurants/new"] = _ => { Restaurant newRestaurant = new Restaurant(Request.Form["restaurant-name"], Request.Form["restaurant-location"], Request.Form["cuisine-id"]); newRestaurant.Save(); return(View["success.cshtml"]); }; Get["/restaurants/new_review"] = _ => { List <Restaurant> allRestaurants = Restaurant.GetAll(); return(View["review_add.cshtml", allRestaurants]); }; Post["/reviews/new"] = _ => { Review newReview = new Review(Request.Form["review-UserName"], Request.Form["review-score"], Request.Form["review-comment"], Request.Form["restaurant-id"]); newReview.Save(); 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(); model.Add("cuisine", selectedCuisine); model.Add("restaurants", cuisineRestaurants); return(View["cuisine.cshtml", model]); }; Get["cuisines/{id}/edit"] = parameters => { Dictionary <string, object> model = new Dictionary <string, object>(); Cuisine selectedCuisine = Cuisine.Find(parameters.id); model.Add("selectedCuisine", selectedCuisine); return(View["cuisine_edit.cshtml", model]); }; Get["/restaurants/{id}"] = parameters => { Dictionary <string, object> model = new Dictionary <string, object>(); var selectedRestaurant = Restaurant.Find(parameters.id); var restaurantReviews = selectedRestaurant.GetReviews(); var restaurantAvgReviews = Review.GetRestaurantAverage(parameters.id); model.Add("restaurant", selectedRestaurant); model.Add("reviews", restaurantReviews); model.Add("average", restaurantAvgReviews); return(View["restaurant.cshtml", model]); }; Get["restaurants/{id}/login"] = parameters => { Dictionary <string, object> model = new Dictionary <string, object>(); var selectedRestaurant = Restaurant.Find(parameters.id); model.Add("restaurant", selectedRestaurant); return(View["login.cshtml", model]); }; Post["restaurants/{id}/login/edit"] = _ => { Admin adminTest = new Admin(Request.Form["user-name"], Request.Form["user-password"]); bool isAdmin = adminTest.CheckPassword(); if (isAdmin) { Admin.SetStatus(true); return(View["restaurant_edit.cshtml"]); } return(View["restaurant_edit.cshtml"]); }; // Patch["/cuisines/{id}/edit"] = parameters => { // Cuisine selectedCuisine = Cuisine.Find(parameters.id); // string newType = Request.Form["cuisine-type"]; // string newDescription = Request.Form["cuisine-description"]; // if (newType == "" && newDescription != "") // { // selectedCuisine.UpdateDescription(newDescription); // } // else if (newType != "" && newDescription == "") // { // selectedCuisine.UpdateType(newType); // } // else // { // selectedCuisine.UpdateDescription(newDescription); // selectedCuisine.UpdateType(newType); // } // return View["success.cshtml"]; // }; Patch["/restaurants/{id}/edit"] = parameters => { Restaurant selectedRestaurant = Restaurant.Find(parameters.id); string newName = Request.Form["restaurant-name"]; string newLocation = Request.Form["restaurant-location"]; if (newName == "" && newLocation != "") { selectedRestaurant.UpdateLocation(newLocation); } else if (newName != "" && newLocation == "") { selectedRestaurant.UpdateName(newName); } else { selectedRestaurant.UpdateLocation(newLocation); selectedRestaurant.UpdateName(newName); } return(View["success.cshtml"]); }; Get["restaurants/{id}/login/edit"] = parameters => { Dictionary <string, object> model = new Dictionary <string, object>(); Restaurant selectedRestaurant = Restaurant.Find(parameters.id); model.Add("restaurant", selectedRestaurant); // model.Add("access", Admin.GetStatus()); return(View["restaurant_edit.cshtml", model]); }; Get["restaurants/{id}/login/delete"] = parameters => { Restaurant selectedRestaurant = Restaurant.Find(parameters.id); return(View["restaurant_delete.cshtml", selectedRestaurant]); }; Delete["restaurants/{id}/delete"] = parameters => { Restaurant selectedRestaurant = Restaurant.Find(parameters.id); selectedRestaurant.Delete(); return(View["success.cshtml"]); }; }
public HomeModule() { Get["/"] = _ => { return(View["index.cshtml"]); }; Get["/restaurants"] = _ => { List <Restaurant> AllRestaurants = Restaurant.GetAll(); return(View["restaurants.cshtml", AllRestaurants]); }; Get["/cuisines"] = _ => { List <Cuisine> AllCuisine = Cuisine.GetAll(); return(View["cuisines.cshtml", AllCuisine]); }; Get["/restaurant/new"] = _ => { List <Cuisine> AllCuisine = Cuisine.GetAll(); return(View["/add_restaurant.cshtml", AllCuisine]); }; Get["/cuisine/new"] = _ => { return(View["/add_cuisine.cshtml"]); }; Post["/restaurants"] = _ => { Dictionary <string, object> model = new Dictionary <string, object>(); Restaurant newRestaurant = new Restaurant(Request.Form["restaurant"], Request.Form["style"], Request.Form["cuisine_id"]); var selectedCuisine = Cuisine.Find(newRestaurant.GetCuisineId()); newRestaurant.Save(); model.Add("cuisine", selectedCuisine); model.Add("restaurant", newRestaurant); return(View["restaurant_added.cshtml", model]); }; Post["/cuisines"] = _ => { Cuisine newCuisine = new Cuisine(Request.Form["cuisine-type"], Request.Form["menu"]); newCuisine.Save(); return(View["cuisine_added.cshtml", newCuisine]); }; Get["/restaurants/{id}"] = parameters => { Dictionary <string, object> model = new Dictionary <string, object>(); var selectedRestaurant = Restaurant.Find(parameters.id); var selectedCuisine = Cuisine.Find(selectedRestaurant.GetCuisineId()); model.Add("cuisine", selectedCuisine); model.Add("restaurant", selectedRestaurant); return(View["restaurant.cshtml", model]); }; Get["/cuisines/{id}"] = parameters => { Dictionary <string, object> model = new Dictionary <string, object>(); var selectedCuisine = Cuisine.Find(parameters.id); var RestaurantsCuisine = selectedCuisine.GetRestaurants(); model.Add("cuisine", selectedCuisine); model.Add("restaurants", RestaurantsCuisine); return(View["cuisine.cshtml", model]); }; Post["/cuisines/cleared"] = _ => { Restaurant.DeleteAll(); Cuisine.DeleteAll(); return(View["cleared.cshtml"]); }; Post["/restaurants/cleared"] = _ => { Restaurant.DeleteAll(); return(View["cleared.cshtml"]); }; 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-menu"]); return(View["success.cshtml"]); }; Get["/restaurant/edit/{id}"] = parameters => { Restaurant selectedRestaurant = Restaurant.Find(parameters.id); return(View["restaurant_edit.cshtml", selectedRestaurant]); }; Patch["/restaurant/edit/{id}"] = parameters => { Restaurant SelectedRestaurant = Restaurant.Find(parameters.id); SelectedRestaurant.Update(Request.Form["restaurant-name"], Request.Form["restaurant-style"]); 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["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"]); }; }