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_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 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"]); }; }