public void Test_Delete_ReturnsTrueIfListsAreTheSame()
        {
            //Arrange
            ContactInfo firstContactInfo = new ContactInfo("123 First st. Portland, OR", 1234567890, 2);

            firstContactInfo.Save();

            ContactInfo secondContactInfo = new ContactInfo("906 President st. Brooklyn, NY", 2128675309, 2);

            secondContactInfo.Save();

            ContactInfo thirdContactInfo = new ContactInfo("316 10th st. Brooklyn, NY", 2024567890, 2);

            thirdContactInfo.Save();

            List <ContactInfo> expectedList = new List <ContactInfo> {
                firstContactInfo, secondContactInfo
            };

            //Act
            thirdContactInfo.Delete();
            List <ContactInfo> contactList = ContactInfo.GetAll();

            //Assert
            Assert.Equal(contactList, expectedList);
        }
        public void Test_Find_FindsContactInfoInDatabase()
        {
            //Arrange
            ContactInfo testContactInfo = new ContactInfo("906 President st. Brooklyn, NY", 2128675309, 1);

            testContactInfo.Save();
            //Act
            ContactInfo foundContactInfo = ContactInfo.Find(testContactInfo.GetId());

            //Assert
            Assert.Equal(testContactInfo, foundContactInfo);
        }
        public void Test_Save_AssignsIdToObject()
        {
            //Arrange
            ContactInfo testContactInfo = new ContactInfo("906 President st. Brooklyn, NY", 2128675309, 1);

            //Act
            testContactInfo.Save();
            ContactInfo savedContactInfo = ContactInfo.GetAll()[0];
            int         result           = savedContactInfo.GetId();
            int         testId           = testContactInfo.GetId();

            //Assert
            Assert.Equal(testId, result);
        }
        public void Test_Save_SavesToDatabase()
        {
            //Arrange
            ContactInfo testContactInfo = new ContactInfo("906 President st. Brooklyn, NY", 2128675309, 1);

            //Act
            testContactInfo.Save();
            List <ContactInfo> result   = ContactInfo.GetAll();
            List <ContactInfo> testList = new List <ContactInfo> {
                testContactInfo
            };

            //Assert
            Assert.Equal(testList, result);
        }
        public void Test_Update_ReturnsTrueIfContactInfosAreTheSame()
        {
            //Arrange
            Restaurant newRestaurant = new Restaurant("Saburos", "a sushi place", 2, 1);

            newRestaurant.Save();
            ContactInfo firstContactInfo = new ContactInfo("123 First st. Portland, OR", 2128675309, newRestaurant.GetId());

            firstContactInfo.Save();
            ContactInfo secondContactInfo = new ContactInfo("906 President st. Brooklyn, NY", 2128675309, newRestaurant.GetId(), firstContactInfo.GetId());

            //Act
            secondContactInfo.Update("123 First st. Portland, OR");
            //Assert
            Assert.Equal(firstContactInfo, secondContactInfo);
        }
        public HomeModule()
        {
            Get["/"] = _ => {
                return(View["index.cshtml"]);
            }; //homepage

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

            Get["/restaurants"] = _ => {
                List <Restaurant> allRestaurants = Restaurant.GetAll();
                return(View["restaurants.cshtml", allRestaurants]);
            }; //list of all restaurants

            Get["/cuisines/new"] = _ => {
                return(View["cuisines_form.cshtml"]);
            }; //navigates to form to add new cuisine

            Post["/cuisines/new"] = _ => {
                Cuisine newCuisine = new Cuisine(Request.Form["cuisine-name"]);
                newCuisine.Save();
                List <Cuisine> allCuisines = Cuisine.GetAll();
                return(View["cuisines.cshtml", allCuisines]);
            }; //posts from form adding new cuisine, returns list of all cuisines

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

            Post["/restaurants/new"] = _ => {
                Restaurant newRestaurant = new Restaurant(Request.Form["restaurant-name"], Request.Form["restaurant-description"], Request.Form["cuisine-id"]);
                newRestaurant.Save();
                List <Restaurant> allRestaurants = Restaurant.GetAll();
                return(View["restaurants.cshtml", allRestaurants]);
            }; //posts from form adding new restaurant, returns list of all restaurants

            Get["/restaurant/new/address/{id}"] = parameters => {
                Restaurant SelectedRestaurant = Restaurant.Find(parameters.id);
                return(View["address_form.cshtml", SelectedRestaurant]);
            }; //navigates to form to add address to restaurant

            Post["/address/new"] = _ => {
                ContactInfo newContactInfo = new ContactInfo(Request.Form["restaurant-address"], Request.Form["restaurant-phone"], Request.Form["selected-restaurant"]);
                newContactInfo.Save();
                Restaurant                  ReferenceRestaurant   = Restaurant.Find(Request.Form["selected-restaurant"]);
                List <ContactInfo>          RestaurantContactInfo = ReferenceRestaurant.GetContacts();
                Dictionary <string, object> model = new Dictionary <string, object>();
                model.Add("contacts", RestaurantContactInfo);
                model.Add("restaurant", ReferenceRestaurant);
                return(View["restaurant.cshtml", model]);
            }; //returns individual restaurant page with contact info

            Post["/cuisines/clear"] = _ => {
                Cuisine.DeleteAll();
                return(View["cuisines.cshtml"]);
            }; //deletes all cuisines

            Post["/restaurants/clear"] = _ => {
                Restaurant.DeleteAll();
                return(View["restaurants.cshtml"]);
            }; //deletes all restaurants

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

            Get["/cuisine/edit/{id}"] = parameters => {
                Dictionary <string, object> model = new Dictionary <string, object> {
                };
                Cuisine SelectedCuisine           = Cuisine.Find(parameters.id);
                string  cuisineEdit = Request.Query["cuisine-edit"];
                model.Add("form-type", cuisineEdit);
                model.Add("cuisine", SelectedCuisine);
                return(View["edit.cshtml", model]);
            }; //edit individual cuisine

            Patch["/cuisine/edit/{id}"] = parameters => {
                Dictionary <string, object> model = new Dictionary <string, object>();
                Cuisine SelectedCuisine           = Cuisine.Find(parameters.id);
                SelectedCuisine.Update(Request.Form["cuisine-name"]);
                List <Restaurant> CuisineRestaurants = SelectedCuisine.GetRestaurants();
                model.Add("cuisine", SelectedCuisine);
                model.Add("restaurants", CuisineRestaurants);
                return(View["cuisine.cshtml", model]);
            }; //returns edited cuisine page

            Get["cuisine/delete/{id}"] = parameters => {
                Dictionary <string, object> model = new Dictionary <string, object> {
                };
                Cuisine SelectedCuisine           = Cuisine.Find(parameters.id);
                string  cuisineDelete             = Request.Query["cuisine-delete"];
                model.Add("form-type", cuisineDelete);
                model.Add("cuisine", SelectedCuisine);
                return(View["delete.cshtml", model]);
            }; //delete individual cuisine

            Delete["cuisine/delete/{id}"] = parameters => {
                Cuisine SelectedCuisine = Cuisine.Find(parameters.id);
                SelectedCuisine.Delete();
                List <Cuisine> allCuisines = Cuisine.GetAll();
                return(View["cuisines.cshtml", allCuisines]);
            }; //returns confirmation of deleted cuisine

            Get["/restaurants/{id}"] = parameters => {
                Restaurant                  SelectedRestaurant    = Restaurant.Find(parameters.id);
                List <ContactInfo>          RestaurantContactInfo = SelectedRestaurant.GetContacts();
                Dictionary <string, object> model = new Dictionary <string, object>();
                model.Add("restaurant", SelectedRestaurant);
                model.Add("contacts", RestaurantContactInfo);
                return(View["restaurant.cshtml", model]);
            }; //retrieves individual restaurant pages

            Get["/restaurant/edit/{id}"] = parameters => {
                Dictionary <string, object> model = new Dictionary <string, object> {
                };
                Restaurant SelectedRestaurant     = Restaurant.Find(parameters.id);
                string     restaurantEdit         = Request.Query["restaurant-edit"];
                model.Add("form-type", restaurantEdit);
                model.Add("restaurant", SelectedRestaurant);
                return(View["edit.cshtml", model]);
            }; //edit individual restaurants

            Patch["/restaurant/edit/{id}"] = parameters => {
                Restaurant SelectedRestaurant = Restaurant.Find(parameters.id);
                SelectedRestaurant.Update(Request.Form["restaurant-name"], Request.Form["restaurant-description"]);
                List <ContactInfo>          RestaurantContactInfo = SelectedRestaurant.GetContacts();
                Dictionary <string, object> model = new Dictionary <string, object>();
                model.Add("restaurant", SelectedRestaurant);
                model.Add("contacts", RestaurantContactInfo);
                return(View["restaurant.cshtml", model]);
            }; //returns edited restaurant page

            Get["restaurant/delete/{id}"] = parameters => {
                Dictionary <string, object> model = new Dictionary <string, object> {
                };
                Restaurant SelectedRestaurant     = Restaurant.Find(parameters.id);
                string     restaurantDelete       = Request.Query["restaurant-delete"];
                model.Add("form-type", restaurantDelete);
                model.Add("restaurant", SelectedRestaurant);
                return(View["delete.cshtml", model]);
            }; //delete individual restaurant

            Delete["restaurant/delete/{id}"] = parameters => {
                Restaurant SelectedRestaurant = Restaurant.Find(parameters.id);
                SelectedRestaurant.Delete();
                List <Restaurant> allRestaurants = Restaurant.GetAll();
                return(View["restaurants.cshtml", allRestaurants]);
            }; //returns list of all restaurants
        }