コード例 #1
0
        public void Test_Save_Find_FoundItemEqualsItem()
        {
            //Arrange/Act
              Stylist item = new Stylist("Sherri", "M-W-F", "Clients love her.");
              item.Save();

              //Assert
              Assert.Equal(Stylist.Find(item.id), item);
        }
コード例 #2
0
ファイル: StylistsTest.cs プロジェクト: Rouz1130/hair-salon
        public void Test5_Find_NewStylistInDatabase()
        {
            Stylist testStylist = new Stylist ("Maggy");
              testStylist.Save();

              Stylist foundStylist = Stylist.Find(testStylist.GetId());

              Assert.Equal(testStylist, foundStylist);
        }
コード例 #3
0
ファイル: StylistsTest.cs プロジェクト: Rouz1130/hair-salon
        public void Test3_SavesToDatabase()
        {
            Stylist testStylist = new Stylist("Jimmy");

              testStylist.Save();
              List<Stylist> result = Stylist.GetAll();
              List<Stylist> testList = new List<Stylist>{testStylist};

              Assert.Equal(testList, result);
        }
コード例 #4
0
        public void Test_Delete()
        {
            //Arrange/Act
              Stylist item = new Stylist("Sherri", "M-W-F", "Clients love her.");
              item.Save();
              item.Delete();

              //Assert
              Assert.Equal(Stylist.Find(item.id), null);
        }
コード例 #5
0
        public void Test_Save_CanRetrieveOneItem()
        {
            //Arrange/Act
              Stylist item = new Stylist("Sherri", "M-W-F", "Clients love her.");
              item.Save();
              List<Stylist> allStylists = Stylist.GetAll();

              //Assert
              Assert.Equal(1, allStylists.Count);
        }
コード例 #6
0
ファイル: StylistsTest.cs プロジェクト: Rouz1130/hair-salon
        public void Test4_Save_AssignIdToObject()
        {
            Stylist testStylist = new Stylist("Anthony");

              testStylist.Save();
              Stylist savedStylist = Stylist.GetAll()[0];

              int result = savedStylist.GetId();
              int testId = testStylist.GetId();

              Assert.Equal(testId, result);
        }
コード例 #7
0
        public void Test_GetClients()
        {
            //Arrange
              Stylist item = new Stylist("Sherri", "M-W-F", "Clients love her.");
              item.Save();
              Client a = new Client("Janet", item.id, "She's a handful.");
              a.Save();

              //Act
              List<Client> clients = item.GetClients();

              //Assert
              Assert.Equal(clients[0], a);
        }
コード例 #8
0
        public void Test_GetStylists_ReturnsTrueIfListsAreTheSame()
        {
            //Arrange
            Salon newSalon = new Salon("British Hairways", "a great salon");

            newSalon.Save();
            Stylist firstTestStylist = new Stylist("Harry Cutter", "a great stylist", newSalon.GetId());

            firstTestStylist.Save();
            Stylist secondTestStylist = new Stylist("Dwayne Johnson", "a wonderful stylist", newSalon.GetId());

            secondTestStylist.Save();
            Stylist thirdTestStylist = new Stylist("Jason Statham", "a marvelous stylist", newSalon.GetId());

            thirdTestStylist.Save();
            List <Stylist> expectedList = Stylist.GetAll();
            //Act
            List <Stylist> resultList = newSalon.GetStylists();

            //Arrange
            Assert.Equal(resultList, expectedList);
        }
コード例 #9
0
        public void TestStylist_SearchByName_ReturnsMatches()
        {
            Stylist stylist1 = new Stylist("Jessica", 5);

            stylist1.Save();
            Stylist stylist2 = new Stylist("Joan", 3);

            stylist2.Save();
            Stylist stylist3 = new Stylist("Rebecca", 4);

            stylist3.Save();
            Stylist stylist4 = new Stylist("John", 4);

            stylist4.Save();

            List <Stylist> controlList = new List <Stylist> {
                stylist4
            };
            List <Stylist> matches = Stylist.SearchByName("John");

            Assert.Equal(controlList, matches);
        }
コード例 #10
0
ファイル: StylistTest.cs プロジェクト: asonna/Hair-Salon
        public void T6_GetClients_RetrievesAllClientsWithStylist()
        {
            //Arrange
            Stylist testStylist = new Stylist("Amy Zee");

            testStylist.Save();

            //Act
            Client clientOne = new Client("Joe Lee", testStylist.GetId());
            Client clientTwo = new Client("Col Day", testStylist.GetId());

            clientOne.Save();
            clientTwo.Save();

            List <Client> testClientList = new List <Client> {
                clientOne, clientTwo
            };
            List <Client> resultClientList = testStylist.GetClients();

            //Assert
            Assert.Equal(testClientList, resultClientList);
        }
コード例 #11
0
        public void Test_GetClients_ReturnsTrueIfListsAreTheSame()
        {
            //Arrange
            Stylist newStylist = new Stylist("Harry Cutter", "a great stylist", 3);

            newStylist.Save();
            Client firstTestClient = new Client("Vin Diesel", newStylist.GetId());

            firstTestClient.Save();
            Client secondTestClient = new Client("Lady Gaga", newStylist.GetId());

            secondTestClient.Save();
            Client thirdTestClient = new Client("Mandy Moore", newStylist.GetId());

            thirdTestClient.Save();
            List <Client> expectedList = Client.GetAll();
            //Act
            List <Client> resultList = newStylist.GetClients();

            //Arrange
            Assert.Equal(resultList, expectedList);
        }
コード例 #12
0
        public void Test_GetClients_ReturnsAllClientsWithinCategory()
        {
            Stylist stylist1 = new Stylist("Giovanni", "(555)555-5555", "Fast, does good work.");
            Stylist stylist2 = new Stylist("Frank", "(555)111-2222", "Could be faster.");

            stylist1.Save();
            stylist2.Save();

            Client client1 = new Client("Mako", "Tips well, comes in once a week.", stylist2.GetId());
            Client client2 = new Client("Yukiko", "Tips well, comes in once a week.", stylist1.GetId());
            Client client3 = new Client("Sayako", "Tips well, comes in once a week.", stylist2.GetId());

            client1.Save();
            client2.Save();
            client3.Save();

            List <Client> expectedClients = new List <Client> {
                client1, client3
            };
            List <Client> results = stylist2.GetClients();

            Assert.Equal(expectedClients, results);
        }
コード例 #13
0
        public void Test_Delete_ReturnsTrueIfListsAreTheSame()
        {
            //Arrange
            Stylist firstTestStylist = new Stylist("Harry Cutter", "a great stylist", 3);

            firstTestStylist.Save();
            Stylist secondTestStylist = new Stylist("Dwayne Johnson", "a wonderful stylist", 2);

            secondTestStylist.Save();
            Stylist thirdTestStylist = new Stylist("Jason Statham", "a marvelous stylist", 1);

            thirdTestStylist.Save();
            List <Stylist> expectedList = new List <Stylist> {
                firstTestStylist, secondTestStylist
            };

            //Act
            thirdTestStylist.Delete();
            List <Stylist> resultList = Stylist.GetAll();

            //Assert
            Assert.Equal(resultList, expectedList);
        }
コード例 #14
0
ファイル: Client_Test.cs プロジェクト: GrapeSalad/Hair-Salon
        public void Test_Delete_DeletesClientFromDatabase()
        {
            string  firstName1   = "French";
            string  lastName1    = "Fry";
            string  specialty1   = "Oil Blast";
            Stylist testStylist1 = new Stylist(firstName1, lastName1, specialty1);

            testStylist1.Save();

            string  firstName2   = "Chunky";
            string  lastName2    = "Monkey";
            string  specialty2   = "Grooming";
            Stylist testStylist2 = new Stylist(firstName2, lastName2, specialty2);

            testStylist2.Save();

            Client testClient1 = new Client("Franz", testStylist1.GetId());

            testClient1.Save();
            Client testClient2 = new Client("Hanz", testStylist2.GetId());

            testClient2.Save();

            testClient1.Delete();
            List <Stylist> resultStylists  = Stylist.GetAll();
            List <Stylist> testStylistList = new List <Stylist> {
                testStylist1, testStylist2
            };

            List <Client> resultClients  = Client.GetAll();
            List <Client> testClientList = new List <Client> {
                testClient2
            };

            Assert.Equal(testStylistList, resultStylists);
            Assert.Equal(testClientList, resultClients);
        }
コード例 #15
0
        public void Test_DeletesStylistFromDatabase_True()
        {
            //Arrange
            string  stylistName1 = "Jordan Loop";
            Stylist testStylist1 = new Stylist(stylistName1);

            testStylist1.Save();

            string  stylistName2 = "Donald Duck";
            Stylist testStylist2 = new Stylist(stylistName2);

            testStylist2.Save();

            Client testClient1 = new Client("Anne McCaffery", testStylist1.GetId());

            testClient1.Save();
            Client testClient2 = new Client("Neil Armstrong", testStylist2.GetId());

            testClient2.Save();

            //Act
            testStylist1.Delete();

            List <Stylist> resultStylistList = Stylist.GetAll();
            List <Stylist> testStylistList   = new List <Stylist> {
                testStylist2
            };

            List <Client> resultClientList = Client.GetAll();
            List <Client> testClientList   = new List <Client> {
                testClient2
            };

            //Assert
            Assert.Equal(testStylistList, resultStylistList);
            Assert.Equal(testClientList, resultClientList);
        }
コード例 #16
0
        public void Delete_DeletesStylistFromDatabase()
        {
            //Arrange
            string  name1        = "Ally Berry";
            Stylist testStylist1 = new Stylist(name1);

            testStylist1.Save();

            string  name2        = "Veronique Moore";
            Stylist testStylist2 = new Stylist(name2);

            testStylist2.Save();

            Client testClient1 = new Client("Carole", testStylist1.GetId());

            testClient1.Save();
            Client testClient2 = new Client("Ruth", testStylist2.GetId());

            testClient2.Save();

            //Act
            testStylist1.Delete();
            List <Stylist> resultStylists  = Stylist.GetAll();
            List <Stylist> testStylistList = new List <Stylist> {
                testStylist2
            };

            List <Client> resultClients  = Client.GetAll();
            List <Client> testClientList = new List <Client> {
                testClient2
            };

            //Assert
            Assert.Equal(testStylistList, resultStylists);
            Assert.Equal(testClientList, resultClients);
        }
コード例 #17
0
ファイル: StylistTest.cs プロジェクト: asonna/Hair-Salon
        public void T8_Delete_DeleteStylistFromDatabase()
        {
            //Arrange
            string  name1        = "Jane May";
            Stylist testStylist1 = new Stylist(name1);

            testStylist1.Save();

            string  name2        = "Ike Lee";
            Stylist testStylist2 = new Stylist(name2);

            testStylist2.Save();

            Client testClient1 = new Client("Mary Lee", testStylist1.GetId());

            testClient1.Save();
            Client testClient2 = new Client("Dan Dan", testStylist2.GetId());

            testClient2.Save();

            //Act
            testStylist1.Delete();
            List <Stylist> resultStylists  = Stylist.GetAll();
            List <Stylist> testStylistList = new List <Stylist> {
                testStylist2
            };

            List <Client> resultClients  = Client.GetAll();
            List <Client> testClientList = new List <Client> {
                testClient2
            };

            //Assert
            Assert.Equal(testStylistList, resultStylists);
            Assert.Equal(testClientList, resultClients);
        }
コード例 #18
0
        public void FindClients_FindsClientsByStylistId_true()
        {
            //Arrange
            Stylist newStylist1 = new Stylist("Serenity");
            Stylist newStylist2 = new Stylist("Dawn");

            newStylist1.Save();
            newStylist2.Save();
            Client client1 = new Client("client1", newStylist1.GetId());
            Client client2 = new Client("client2", newStylist2.GetId());
            Client client3 = new Client("client3", newStylist1.GetId());

            client1.Save();
            client2.Save();
            client3.Save();
            List <Client> expectedResult = new List <Client> {
                client1, client3
            };
            //Act
            List <Client> result = newStylist1.FindClients();

            //Assert
            Assert.Equal(expectedResult, result);
        }
コード例 #19
0
 public HomeModule()
 {
     Get["/"] = _ => {
         return(View["/index.cshtml"]);
     };
     Get["/add-new-stylist"] = _ => {
         return(View["/add-new-stylist.cshtml"]);
     };
     Get["/add-new-client"] = _ => {
         var allStylists = Stylist.GetAll();
         return(View["/add-new-client.cshtml", allStylists]);
     };
     Get["/success-stylist"] = _ => {
         return(View["/success-stylist.cshtml"]);
     };
     Get["/stylists"] = _ => {
         var allStylists = Stylist.GetAll();
         return(View["/stylists.cshtml", allStylists]);
     };
     Get["/clients"] = _ => {
         List <Client> allClients = Client.GetAll();
         return(View["/clients.cshtml", allClients]);
     };
     Post["/added-stylist"] = _ => {
         Stylist newStylist = new Stylist(Request.Form["stylist-name"], Request.Form["stylist-details"]);
         newStylist.Save();
         return(View["/success-stylist.cshtml"]);
     };
     Post["/added-client"] = _ => {
         Client newClient = new Client(Request.Form["client-name"], Request.Form["client-details"], Request.Form["client-stylist"]);
         newClient.Save();
         return(View["/success-client.cshtml"]);
     };
     Get["/stylist/update/{id}"] = parameters => {
         Stylist SelectedStylist = Stylist.Find(parameters.id);
         return(View["/stylist-update.cshtml", SelectedStylist]);
     };
     Patch["/stylist/update/{id}"] = parameters => {
         Stylist SelectedStylist = Stylist.Find(parameters.id);
         SelectedStylist.Update(Request.Form["stylist-details"]);
         return(View["/success-stylist-update.cshtml"]);
     };
     Get["/client/update/{id}"] = parameters => {
         Client SelectedClient = Client.Find(parameters.id);
         return(View["client-update.cshtml", SelectedClient]);
     };
     Patch["/client/update/{id}"] = parameters => {
         Client SelectedClient = Client.Find(parameters.id);
         SelectedClient.Update(Request.Form["client-details"]);
         return(View["/success-stylist-update.cshtml"]);
     };
     Get["/stylist/{id}"] = parameters => {
         Stylist selectedStylist           = Stylist.Find(parameters.id);
         Dictionary <string, object> model = new Dictionary <string, object>();
         List <Client> stylistClients      = selectedStylist.GetClients();
         model.Add("stylist", selectedStylist);
         model.Add("stylistClients", stylistClients);
         return(View["stylist.cshtml", model]);
     };
     Get["/client/{id}"] = parameters => {
         Client selectedClient             = Client.Find(parameters.id);
         Dictionary <string, object> model = new Dictionary <string, object>();
         int     clientStylistId           = selectedClient.GetClientStylistId();
         Stylist clientStylist             = Stylist.Find(clientStylistId);
         model.Add("client", selectedClient);
         model.Add("clientStylist", clientStylist);
         return(View["client.cshtml", model]);
     };
     Get["/stylist/delete/{id}"] = parameters => {
         Stylist SelectedStylist = Stylist.Find(parameters.id);
         SelectedStylist.Delete();
         return(View["/success-stylist-delete.cshtml"]);
     };
     Get["/client/delete/{id}"] = parameters => {
         Client SelectedClient = Client.Find(parameters.id);
         SelectedClient.Delete();
         return(View["/success-client-delete.cshtml"]);
     };
 }
コード例 #20
0
        public HomeModule()
        {
            //root -> index.cshtml
            Get["/"] = _ => {
                return(View["index.cshtml"]);
            };

            //stylist/all -> all-stylist.cshtml
            Get["/stylist/all"] = _ => {
                List <Stylist> allStylists = Stylist.GetAll();
                return(View["all-stylist.cshtml", allStylists]);
            };

            //stylist/add -> add-stylist.cshtml
            Get["/stylist/add"] = _ => {
                return(View["add-stylist.cshtml"]);
            };

            Post["/stylist/add"] = _ => {
                Stylist newStylist = new Stylist(Request.Form["stylist-name"]);
                newStylist.Save();
                List <Stylist> allStylists = Stylist.GetAll();
                return(View["all-stylist.cshtml", allStylists]);
            };

            //stylist/add -> all-stylist
            Post["/stylist/delete-all"] = _ => {
                Stylist.DeleteAll();
                return(View["confirmed.cshtml"]);
            };

            Get["/stylist/view/{id}"] = param => {
                Dictionary <string, object> model = new Dictionary <string, object>();
                Stylist       selectedStylist     = Stylist.Find(param.id);
                List <Client> stylistClients      = selectedStylist.GetClient();

                model.Add("Stylist", selectedStylist);
                model.Add("Clients", stylistClients);
                return(View["view-stylist.cshtml", model]);
            };


            Get["/client/add"] = _ => {
                List <Stylist> allStylists = Stylist.GetAll();
                return(View["add-client.cshtml", allStylists]);
            };

            Post["/client/add"] = _ => {
                Client newClient = new Client(Request.Form["client-name"], Request.Form["stylist-id"]);
                newClient.Save();
                List <Client> allClients = Client.GetAll();
                return(View["all-client.cshtml", allClients]);
            };

            Delete["/client/delete/{id}"] = param => {
                Client selectedClient = Client.Find(param.id);
                selectedClient.Delete();
                return(View["confirmed.cshtml"]);
            };

            Get["/client/edit/{id}"] = param => {
                Client selectedClient = Client.Find(param.id);
                return(View["edit-client.cshtml", selectedClient]);
            };
            Patch["client/edit/{id}"] = param => {
                Client SelectedClient = Client.Find(param.id);
                SelectedClient.Update(Request.Form["edit-client"]);
                return(View["confirmed.cshtml"]);
            };
        }
コード例 #21
0
        public void Test_Update()
        {
            //Arrange/Act
              Stylist item = new Stylist("Sherri", "M-W-F", "Clients love her.");
              item.Save();
              item.Update(new List<string>{"name"}, new List<object>{"Sherry"});

              //Assert
              Assert.Equal(Stylist.Find(item.id).name, "Sherry");
        }
コード例 #22
0
 public HomeModule()
 {
     Get["/"] = _ => {
         return(View["index.cshtml"]);
     };
     //CREATE
     Get["/client/new"] = _ => {
         List <Stylist> AllStylists = Stylist.GetAll();
         return(View["add_client.cshtml", AllStylists]);
     };
     Get["/stylist/new"] = _ => {
         return(View["add_stylist.cshtml"]);
     };
     Post["/clients"] = _ => {
         Dictionary <string, object> model = new Dictionary <string, object>();
         Client newClient       = new Client(Request.Form["client-name"], Request.Form["client-phone"], Request.Form["client-email"], Request.Form["stylist"]);
         var    selectedStylist = Stylist.Find(newClient.GetStylistId());
         newClient.Save();
         model.Add("stylist", selectedStylist);
         model.Add("client", newClient);
         return(View["success.cshtml", model]);
     };
     Post["/stylists"] = _ => {
         Dictionary <string, object> model = new Dictionary <string, object>();
         Stylist newStylist      = new Stylist(Request.Form["stylist-name"], Request.Form["stylist-phone"], Request.Form["stylist-email"]);
         var     selectedStylist = Stylist.Find(newStylist.GetId());
         newStylist.Save();
         model.Add("stylist", newStylist);
         return(View["success.cshtml", newStylist]);
     };
     //READ
     Get["/clients"] = _ => {
         List <Client> AllClients = Client.GetAll();
         return(View["clients.cshtml", AllClients]);
     };
     Get["/stylists"] = _ => {
         List <Stylist> AllStylist = Stylist.GetAll();
         return(View["stylists.cshtml", AllStylist]);
     };
     Get["/clients/{id}"] = parameters => {
         Dictionary <string, object> model = new Dictionary <string, object>();
         var selectedClient  = Client.Find(parameters.id);
         var selectedStylist = Stylist.Find(selectedClient.GetStylistId());
         model.Add("stylist", selectedStylist);
         model.Add("client", selectedClient);
         return(View["client.cshtml", model]);
     };
     Get["/stylists/{id}"] = parameters => {
         Dictionary <string, object> model = new Dictionary <string, object>();
         var selectedStylist = Stylist.Find(parameters.id);
         var ClientsStylist  = selectedStylist.GetClients();
         model.Add("stylist", selectedStylist);
         model.Add("clients", ClientsStylist);
         return(View["stylist.cshtml", model]);
     };
     //UPDATE
     Get["/client/edit/{id}"] = parameters => {
         Dictionary <string, object> model = new Dictionary <string, object> {
         };
         Client         SelectedClient     = Client.Find(parameters.id);
         List <Stylist> AllStylists        = Stylist.GetAll();
         model.Add("client", SelectedClient);
         model.Add("stylists", Stylist.GetAll());
         return(View["edit_client.cshtml", model]);
     };
     Get["/stylist/edit/{id}"] = parameters => {
         Stylist SelectedStylist = Stylist.Find(parameters.id);
         return(View["edit_stylist.cshtml", SelectedStylist]);
     };
     Patch["/client/edit/{id}"] = parameters => {
         Client SelectedClient  = Client.Find(parameters.id);
         var    selectedStylist = Stylist.Find(SelectedClient.GetStylistId());
         SelectedClient.Update(Request.Form["client-name"], Request.Form["client-phone"], Request.Form["client-email"], Request.Form["stylist-id"]);
         return(View["success.cshtml"]);
     };
     Patch["/stylist/edit/{id}"] = parameters => {
         Stylist SelectedStylist = Stylist.Find(parameters.id);
         SelectedStylist.Update(Request.Form["stylist-name"], Request.Form["stylist-phone"], Request.Form["stylist-email"]);
         return(View["success.cshtml"]);
     };
     //DESTROY
     Get["client/delete/{id}"] = parameters => {
         Client SelectedClient = Client.Find(parameters.id);
         return(View["delete_client.cshtml", SelectedClient]);
     };
     Get["stylist/delete/{id}"] = parameters => {
         Stylist SelectedStylist = Stylist.Find(parameters.id);
         return(View["delete_stylist.cshtml", SelectedStylist]);
     };
     Delete["client/delete/{id}"] = parameters => {
         Client SelectedClient = Client.Find(parameters.id);
         SelectedClient.Delete();
         return(View["success.cshtml"]);
     };
     Delete["stylist/delete/{id}"] = parameters => {
         Stylist SelectedStylist = Stylist.Find(parameters.id);
         SelectedStylist.Delete();
         return(View["success.cshtml"]);
     };
     Post["/clients/cleared"] = _ => {
         Client.DeleteAll();
         return(View["cleared.cshtml"]);
     };
     Post["/stylists/cleared"] = _ => {
         Client.DeleteAll();
         Stylist.DeleteAll();
         return(View["cleared.cshtml"]);
     };
 }
コード例 #23
0
        public HomeModule()
        {
            Get["/"] = _ => {
                return(View["root.cshtml"]);
            };
            Get["/stylists/add"] = _ => {
                return(View["add-stylists.cshtml"]);
            };
            Get["/stylists/all"] = _ => {
                List <Stylist> allStylists = Stylist.GetAll();
                return(View["all-stylists.cshtml", allStylists]);
            };
            Post["stylists/all"] = _ => {
                Stylist newStylist = new Stylist(Request.Form["stylist-name"]);
                newStylist.Save();
                List <Stylist> allStylists = Stylist.GetAll();
                return(View["all-stylists.cshtml", allStylists]);
            };
            Get["/stylists/{id}"] = parameter => {
                Dictionary <string, object> model = new Dictionary <string, object>();
                Stylist       SelectedStylist     = Stylist.Find(parameter.id);
                List <Client> StylistClient       = SelectedStylist.GetClient();
                model.Add("Stylist", SelectedStylist);
                model.Add("Client", StylistClient);
                return(View["clients.cshtml", model]);
            };
            Post["/stylists/delete"] = _ => {
                Stylist.DeleteAll();
                return(View["deleteAll-confirm.cshtml"]);
            };
            Get["/clients/add"] = _ => {
                List <Stylist> allStylists = Stylist.GetAll();
                return(View["add-client.cshtml", allStylists]);
            };
            Post["/clients/all"] = _ => {
                Client newClient = new Client(Request.Form["client-name"], Request.Form["client-id"]);
                newClient.Save();
                return(View["root.cshtml"]);
            };
            Get["client/edit/{id}"] = parameter => {
                Client SelectedClient = Client.Find(parameter.id);
                return(View["edit-client.cshtml", SelectedClient]);
            };
            Patch["client/edit/{id}"] = parameter => {
                Client SelectedClient = Client.Find(parameter.id);
                SelectedClient.Update(Request.Form["edit-client"]);
                List <Client> allClients = Client.GetAll();
                return(View["root.cshtml", allClients]);
            };
            Get["client/delete/{id}"] = parameters => {
                Client SelectedClient = Client.Find(parameters.id);
                return(View["client-delete.cshtml", SelectedClient]);
            };
            Delete["client/delete/{id}"] = parameters => {
                Client SelectedClient = Client.Find(parameters.id);
                SelectedClient.Delete();
                return(View["root.cshtml"]);
            };


            Get["stylist/edit/{id}"] = parameter => {
                Stylist SelectedStylist = Stylist.Find(parameter.id);
                return(View["edit-stylist.cshtml", SelectedStylist]);
            };
            Patch["stylist/edit/{id}"] = parameter => {
                Stylist SelectedStylist = Stylist.Find(parameter.id);
                SelectedStylist.Update(Request.Form["edit-stylist"]);
                List <Stylist> allStylists = Stylist.GetAll();
                return(View["root.cshtml", allStylists]);
            };
            Get["stylist/delete/{id}"] = parameters => {
                Stylist SelectedStylist = Stylist.Find(parameters.id);
                return(View["stylist-delete.cshtml", SelectedStylist]);
            };
            Delete["stylist/delete/{id}"] = parameters => {
                Stylist SelectedStylist = Stylist.Find(parameters.id);
                SelectedStylist.Delete();
                return(View["root.cshtml"]);
            };
        }
コード例 #24
0
        public HomeModule()
        {
            Get["/"] = _ =>
            {
                List <Client> AllClients = Client.GetAll();
                return(View["index.cshtml", AllClients]);
            };

            Get["/stylists"] = _ =>
            {
                List <Stylist> AllStylists = Stylist.GetAll();
                return(View["stylists.cshtml", AllStylists]);
            };
            Post["/stylists"] = _ =>
            {
                Stylist newStylist = new Stylist(Request.Form["stylist-name"]);
                newStylist.Save();
                List <Stylist> AllStylists = Stylist.GetAll();
                return(View["stylists.cshtml", AllStylists]);
            };

            Get["/stylists/new"] = _ =>
            {
                return(View["stylists-form.cshtml"]);
            };

            Get["/stylist/{id}"] = param =>
            {
                Stylist       Found        = Stylist.Find(param.id);
                List <Client> FoundClients = Found.GetClients();
                return(View["stylist.cshtml", FoundClients]);
            };

            Get["/stylists/{id}"] = param =>
            {
                Stylist       FoundStylist  = Stylist.Find(param.id);
                List <Client> ListOfClients = FoundStylist.GetClients();
                return(View["stylist.cshtml", ListOfClients]);
            };

            Post["/stylists/delete"] = _ =>
            {
                Stylist.DeleteAll();
                List <Stylist> AllStylists = Stylist.GetAll();
                return(View["stylists.cshtml", AllStylists]);
            };

            Get["/clients"] = _ =>
            {
                List <Client> AllClients = Client.GetAll();
                return(View["clients.cshtml", AllClients]);
            };

            Post["/clients"] = _ =>
            {
                Client newClient = new Client(Request.Form["client-name"], Request.Form["client-stylist"]);
                newClient.Save();
                List <Client> AllClients = Client.GetAll();
                return(View["clients.cshtml", AllClients]);
            };

            Get["/clients/new"] = _ =>
            {
                List <Stylist> AllStylists = Stylist.GetAll();
                return(View["client-form.cshtml", AllStylists]);
            };

            Post["/clients/new"] = _ =>
            {
                Client newClient = new Client(Request.Form["client-name"], Request.Form["stylist-name"]);
                newClient.Save();
                return(View["success.cshtml"]);
            };

            Get["clients/edit/{id}"] = param =>
            {
                Client SelectedClient = Client.Find(param.id);
                return(View["client_edit.cshtml", SelectedClient]);
            };

            Patch["clients/edit/{id}"] = param =>
            {
                Client SelectedClient = Client.Find(param.id);
                SelectedClient.Update(Request.Form["client-name"]);
                return(View["success.cshtml"]);
            };

            Get["client/delete/{id}"] = param =>
            {
                Client ThisClient = Client.Find(param.id);
                return(View["client-delete.cshtml", ThisClient]);
            };

            Delete["client/delete/{id}"] = param =>
            {
                Client SelectedClient = Client.Find(param.id);
                SelectedClient.Delete();
                return(View["success.cshtml"]);
            };

            Post["/clients/delete"] = _ =>
            {
                Client.DeleteAll();
                List <Client> AllClients = Client.GetAll();
                return(View["success.cshtml", AllClients]);
            };
        }
コード例 #25
0
 public HomeModule()
 {
     Get["/"] = _ => {
         Dictionary <string, object> model = new Dictionary <string, object> {
         };
         model.Add("listStylists", Stylist.GetAll());
         model.Add("listClients", Client.GetAll());
         model.Add("show-info", null);
         return(View["index.cshtml", model]);
     };
     Get["/stylists/new"] = _ => {
         Dictionary <string, string> model = new Dictionary <string, string> {
         };
         model.Add("form-type", "new-stylist");
         return(View["form.cshtml", model]);
     };
     Post["/stylists/new"] = _ => {
         Dictionary <string, object> model = new Dictionary <string, object> {
         };
         Stylist stylist = new Stylist(Request.Form["stylist-name"], Request.Form["stylist-rating"]);
         stylist.Save();
         model.Add("listClients", Client.GetAll());
         model.Add("listStylists", Stylist.GetAll());
         model.Add("newStylist", stylist);
         model.Add("show-info", Request.Form["show-info-new"]);
         return(View["index.cshtml", model]);
     };
     Get["/stylists/{id}/info"] = parameters => {
         Dictionary <string, object> model = new Dictionary <string, object> {
         };
         Stylist foundedStylist            = Stylist.Find(parameters.id);
         model.Add("listClients", Client.GetAll());
         model.Add("foundedStylist", foundedStylist);
         model.Add("show-info", "show-stylist");
         model.Add("listStylists", Stylist.GetAll());
         model.Add("stylistClients", foundedStylist.GetClients());
         return(View["index.cshtml", model]);
     };
     Get["/stylist/{id}/update"] = parameters => {
         Dictionary <string, object> model = new Dictionary <string, object> {
         };
         Stylist foundedStylist            = Stylist.Find(parameters.id);
         model.Add("foundedStylist", foundedStylist);
         model.Add("form-type", "update-stylist");
         model.Add("stylistClients", foundedStylist.GetClients());
         return(View["form.cshtml", model]);
     };
     Patch["/stylists/{id}/update"] = parameters => {
         Dictionary <string, object> model = new Dictionary <string, object> {
         };
         Stylist foundedStylist            = Stylist.Find(parameters.id);
         foundedStylist.Update(Request.Form["stylist-name"], Request.Form["stylist-rating"]);
         model.Add("updatedStylist", foundedStylist);
         model.Add("listClients", Client.GetAll());
         model.Add("listStylists", Stylist.GetAll());
         model.Add("stylistClients", foundedStylist.GetClients());
         model.Add("show-info", "update-stylist");
         return(View["index.cshtml", model]);
     };
     Get["/client/new"] = _ => {
         Dictionary <string, object> model = new Dictionary <string, object> {
         };
         model.Add("form-type", "new-client");
         model.Add("listStylists", Stylist.GetAll());
         return(View["form.cshtml", model]);
     };
     Post["/client/new"] = _ => {
         Dictionary <string, object> model = new Dictionary <string, object> {
         };
         Client client = new Client(Request.Form["client-name"], Request.Form["stylists"]);
         client.Save();
         model.Add("clientStylist", Stylist.Find(client.GetStylistId()));
         model.Add("newClient", client);
         model.Add("listClients", Client.GetAll());
         model.Add("show-info", "client-new");
         model.Add("listStylists", Stylist.GetAll());
         return(View["index.cshtml", model]);
     };
     Get["/clients/{id}/info"] = parameters => {
         Dictionary <string, object> model = new Dictionary <string, object> {
         };
         Client  foundedClient             = Client.Find(parameters.id);
         Stylist foundedStylist            = Stylist.Find(foundedClient.GetStylistId());
         model.Add("listStylists", Stylist.GetAll());
         model.Add("foundedClient", foundedClient);
         model.Add("foundedStylist", foundedStylist);
         model.Add("show-info", "show-client");
         model.Add("listClients", Client.GetAll());
         return(View["index.cshtml", model]);
     };
     Get["/clients/{id}/update"] = parameters => {
         Dictionary <string, object> model = new Dictionary <string, object> {
         };
         Client foundedClient = Client.Find(parameters.id);
         model.Add("foundedClient", foundedClient);
         model.Add("form-type", "update-client");
         model.Add("listStylists", Stylist.GetAll());
         return(View["form.cshtml", model]);
     };
     // Patch["/client/{id}/update"] = parameters => {
     //   Dictionary<string, object> model = new Dictionary<string, object>{};
     //   Client foundedClient = Client.Find(parameters.id);
     //   foundedClient.Update(Request.Form["client-name"], Request.Form["client-rating"]);
     //   model.Add("updatedClient", foundedClient);
     //   model.Add("listClients", Client.GetAll());
     //   model.Add("listStylists", Stylist.GetAll());
     //   model.Add("show-info", "update-client");
     //   return View["index.cshtml", model];
     // };
     Delete["/stylists/{id}/delete"] = parameters => {
         Dictionary <string, object> model = new Dictionary <string, object> {
         };
         Stylist foundedStylist            = Stylist.Find(parameters.id);
         foundedStylist.DeleteSingleStylist();
         model.Add("listStylists", Stylist.GetAll());
         model.Add("listClients", Client.GetAll());
         model.Add("show-info", "delete-stylist");
         model.Add("foundedStylist", foundedStylist);
         return(View["index.cshtml", model]);
     };
     Delete["/clients/{id}/delete"] = parameters => {
         Dictionary <string, object> model = new Dictionary <string, object> {
         };
         Client foundedClient = Client.Find(parameters.id);
         foundedClient.DeleteSingleClient();
         model.Add("listStylists", Stylist.GetAll());
         model.Add("listClients", Client.GetAll());
         model.Add("show-info", "delete-client");
         model.Add("foundedClient", foundedClient);
         return(View["index.cshtml", model]);
     };
     Delete["/stylists/delete_all"] = _ => {
         Dictionary <string, object> model = new Dictionary <string, object> {
         };
         Stylist.DeleteAll();
         model.Add("listStylists", Stylist.GetAll());
         model.Add("listClients", Client.GetAll());
         model.Add("show-info", "delete-all-stylists");
         return(View["index.cshtml", model]);
     };
     Delete["/clients/delete_all"] = _ => {
         Dictionary <string, object> model = new Dictionary <string, object> {
         };
         Client.DeleteAll();
         model.Add("listStylists", Stylist.GetAll());
         model.Add("listClients", Client.GetAll());
         model.Add("show-info", "delete-all-clients");
         return(View["index.cshtml", model]);
     };
 }
コード例 #26
0
 public HomeModule()
 {
     Get["/"] = _ => {
     List<Stylist> stylists = Stylist.GetAll();
     return View["index.cshtml", stylists];
       };
       Post["/stylists/new"] = _ => {
     Stylist newStylist = new Stylist(Request.Form["name"], Request.Form["avail"], Request.Form["notes"]);
     newStylist.Save();
     List<Stylist> stylists = Stylist.GetAll();
     return View["index.cshtml", stylists];
       };
       Get["/stylists/{id}"] = parameter => {
     Stylist foundStylist = Stylist.Find(parameter.id);
     return View["stylist.cshtml", foundStylist];
       };
       Patch["/stylists/edit/{id}"] = parameter => {
     Stylist editedStylist = Stylist.Find(parameter.id);
     List<string> updateColumns = new List<string> {"name", "availability", "notes"};
     string newStylistId = (string)Request.Form["avail"];
     string newName = (string)Request.Form["name"];
     string newNotes = (string)Request.Form["notes"];
     List<object> updateValues = new List<object> {newName, newStylistId, newNotes};
     editedStylist.Update(updateColumns, updateValues);
     return View["stylist.cshtml", editedStylist];
       };
       Delete["/stylists/delete/{id}"] = parameter => {
     Stylist deletedStylist = Stylist.Find(parameter.id);
     deletedStylist.Delete();
     List<Stylist> stylists = Stylist.GetAll();
     return View["index.cshtml", stylists];
       };
       Post["/clients/new"] = _ => {
     string newName = (string)Request.Form["name"];
     int stylistId = (int)Request.Form["stylist_id"];
     string newNotes = (string)Request.Form["notes"];
     Client newClient = new Client(newName, stylistId, newNotes);
     newClient.Save();
     Stylist foundStylist = Stylist.Find(stylistId);
     return View["stylist.cshtml", foundStylist];
       };
       Get["/clients/{id}"] = parameter => {
     Client foundClient = Client.Find(parameter.id);
     List<object> model = new List<object> {};
     model.Add(foundClient);
     model.Add(Stylist.GetAll());
     return View["client.cshtml", model];
       };
       Patch["/clients/edit/{id}"] = parameter => {
     Client editedClient = Client.Find(parameter.id);
     List<string> updateColumns = new List<string> {"name", "stylist_id", "notes"};
     int newStylistId = (int)Request.Form["stylist_id"];
     string newName = (string)Request.Form["name"];
     string newNotes = (string)Request.Form["notes"];
     List<object> updateValues = new List<object> {newName, newStylistId, newNotes};
     editedClient.Update(updateColumns, updateValues);
     List<object> model = new List<object> {};
     model.Add(editedClient);
     model.Add(Stylist.GetAll());
     return View["client.cshtml", model];
       };
       Delete["/clients/delete/{id}"] = parameter => {
     Client deletedClient = Client.Find(parameter.id);
     deletedClient.Delete();
     Stylist foundStylist = Stylist.Find(deletedClient.stylist_id);
     return View["stylist.cshtml", foundStylist];
       };
 }
コード例 #27
0
ファイル: HomeModule.cs プロジェクト: asonna/HairSalon
        public HomeModule()
        {
            Get["/"] = _ =>
            {
                List <Stylist> stylists = Stylist.GetAll();
                return(View["index.cshtml", stylists]);
            };
            ///////////////////////////////////////////////////
            ////RESTFUL ROOTS FOR Stylist                  ////
            //////////////////////////////////////////////////
            Post["/add_stylist"] = _ => {
                Stylist newStylist = new Stylist(Request.Form["stylist"]);
                newStylist.Save();

                List <Stylist> stylists = Stylist.GetAll();
                return(View["index.cshtml", stylists]);
            };
            Get["/delete_all_stylists_and_clients"] = _ =>
            {
                Stylist.DeleteAll();
                Client.DeleteAll();

                List <Stylist> stylists = Stylist.GetAll();
                return(View["index.cshtml", stylists]);
            };
            Get["/edit/{id}"] = parameters =>
            {
                Stylist editStylist = Stylist.Find(parameters.id);
                return(View["change_and_delete_stylist.cshtml", editStylist]);
            };
            Patch["/edit/{id}"] = parameters => {
                Stylist updateStylist = Stylist.Find(parameters.id);
                updateStylist.Update(Request.Form["new_stylist_name"]);
                return(View["success.cshtml"]);
            };
            Delete["/edit/{id}"] = parameters =>
            {
                Stylist removedStylist = Stylist.Find(parameters.id);
                removedStylist.Delete();
                return(View["success.cshtml"]);
            };
            ////////////////////////////////////////////////////////////
            /////  RESTFUL ROUTS FOR CLIENTS                  //////////
            ///////////////////////////////////////////////////////////
            Get["/clients/{id}"] = parameters =>
            {
                Stylist       currentStylist = Stylist.Find(parameters.id);
                List <Client> clients        = currentStylist.FindClients();

                Dictionary <string, object> model = new Dictionary <string, object> {
                };
                model.Add("stylist", currentStylist);
                model.Add("clients", clients);
                return(View["client_list_by_stylist.cshtml", model]);
            };
            Post["/clients/add_client"] = _ =>
            {
                Client newClient = new Client(Request.Form["new_client"], Request.Form["stylist_id"]);
                newClient.Save();

                Stylist       currentStylist = Stylist.Find(Request.Form["stylist_id"]);
                List <Client> clients        = currentStylist.FindClients();

                Dictionary <string, object> model = new Dictionary <string, object> {
                };
                model.Add("stylist", currentStylist);
                model.Add("clients", clients);
                return(View["client_list_by_stylist.cshtml", model]);
            };
            Get["/clients/edit/{id}"] = parameters =>
            {
                Client client = Client.Find(parameters.id);
                return(View["change_and_delete_client.cshtml", client]);
            };
            Patch["/clients/edit/{id}"] = parameters => {
                Client client = Client.Find(parameters.id);
                client.Update(Request.Form["new_client_name"], Request.Form["stylist_id"]);
                return(View["success.cshtml"]);
            };
            Delete["/clients/edit/{id}"] = parameters =>
            {
                Client client = Client.Find(parameters.id);
                client.Delete();
                return(View["success.cshtml"]);
            };
        }
コード例 #28
0
        public Homemodule()
        {
            Get["/"] = _ => {
                List <Stylist> AllStylists = Stylist.GetAll();
                return(View["index.cshtml", AllStylists]);
            };

            Get["/stylists"] = _ => {
                List <Stylist> AllStylists = Stylist.GetAll();
                return(View["stylists.cshtml", AllStylists]);
            };

            Get["/clients"] = _ => {
                List <Client> AllClients = Client.GetAll();
                return(View["clients.cshtml", AllClients]);
            };

            Get["/addAnotherStylist"] = _ => {
                List <Client> AllClients = Client.GetAll();
                return(View["addAnotherStylist.cshtml", AllClients]);
            };

            Get["/addNewClientToStylist"] = _ => {
                List <Stylist> AllStylists = Stylist.GetAll();
                return(View["addNewClientToStylist.cshtml", AllStylists]);
            };

            Post["/addedNewClientToStylist"] = _ => {
                Client newClient = new Client(Request.Form["client-name"], Request.Form["stylist-id"]);
                newClient.Save();
                return(View["addedNewClientToStylist.cshtml"]);
            };

            Post["/addedNewStylist"] = _ => {
                Stylist newStylist = new Stylist(Request.Form["stylist-name"]);
                newStylist.Save();
                return(View["addedNewStylist.cshtml"]);
            };

            Get["/deleteAllStylists"] = _ => {
                Stylist.DeleteAll();
                return(View["deleteAllStylists.cshtml"]);
            };

            Get["/deleteAllClients"] = _ => {
                Client.DeleteAll();
                return(View["deleteAllClients.cshtml"]);
            };

            Get["/viewTheClientsForThisStylist/{id}"] = parameters => {
                Dictionary <string, object> Model = new Dictionary <string, object>();
                Stylist       SelectedStylists    = Stylist.Find(parameters.id);
                List <Client> StylistsClients     = SelectedStylists.GetClients();
                Model.Add("stylists", SelectedStylists);
                Model.Add("clients", StylistsClients);
                return(View["viewTheClientsForThisStylist.cshtml", Model]);
            };

            Get["stylist/edit/{id}"] = parameters => {
                Stylist SelectedStylists = Stylist.Find(parameters.id);
                return(View["stylist_edit.cshtml", SelectedStylists]);
            };

            Patch["stylist/edit/{id}"] = parameters => {
                Stylist SelectedStylists = Stylist.Find(parameters.id);
                SelectedStylists.Update(Request.Form["stylist-name"]);
                return(View["index.cshtml", SelectedStylists]);
            };

            Get["client/edit/{id}"] = parameters => {
                Client SelectedClient = Client.Find(parameters.id);
                return(View["client_edit.cshtml", SelectedClient]);
            };

            Patch["client/edit/{id}"] = parameters => {
                Client SelectedClient = Client.Find(parameters.id);
                SelectedClient.Update(Request.Form["client-name"]);
                return(View["index.cshtml", SelectedClient]);
            };

            Get["stylist/delete/{id}"] = parameters => {
                Stylist SelectedStylist = Stylist.Find(parameters.id);
                return(View["stylist_delete.cshtml", SelectedStylist]);
            };
            Delete["stylist/delete/{id}"] = parameters => {
                Stylist SelectedStylist = Stylist.Find(parameters.id);
                SelectedStylist.Delete();
                return(View["index.cshtml"]);
            };

            Get["client/delete/{id}"] = parameters => {
                Client SelectedClient = Client.Find(parameters.id);
                return(View["client_delete.cshtml", SelectedClient]);
            };
            Delete["client/delete/{id}"] = parameters => {
                Client SelectedClient = Client.Find(parameters.id);
                SelectedClient.Delete();
                return(View["index.cshtml"]);
            };
        }
コード例 #29
0
        public HomeModule()
        {
            Get["/"] = _ => {
                List <Stylist> AllStylists = Stylist.GetAll();
                return(View["index.cshtml", AllStylists]);
            };

            Get["/clients"] = _ => {
                List <Client> AllClients = Client.GetAll();
                return(View["clients.cshtml", AllClients]);
            };

            Get["/clients/new"] = _ => {
                List <Stylist> AllStylists = Stylist.GetAll();
                return(View["clients_form.cshtml", AllStylists]);
            };

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

//
            Post["/stylists/new"] = _ => {
                Stylist newStylist = new Stylist(Request.Form["stylist-name"]);
                newStylist.Save();
                return(View["success.cshtml", newStylist]);
            };

//
            Post["/clients/new"] = _ => {
                Dictionary <string, object> model = new Dictionary <string, object> ();
                string clientName      = Request.Form["client-name"];
                int    clientStylistId = int.Parse(Request.Form["stylistId"]);

                Client newClient = new Client(clientName, clientStylistId);
                newClient.Save();

                Stylist assignedStylist = Stylist.Find(clientStylistId);
                model.Add("client", newClient);
                model.Add("stylist", assignedStylist);
                return(View["success.cshtml", model]);
            };

            //Routes for our individual view pages
            Get["/stylist/{id}"] = parameters => {
                Stylist selectedStylist = Stylist.Find(parameters.id);
                return(View["stylist.cshtml", selectedStylist]);
            };

            Get["/client/{id}"] = parameters => {
                Dictionary <string, object> model = new Dictionary <string, object>();
                Client selectedClient             = Client.Find(parameters.id);
                var    SelectedStylist            = Stylist.Find(selectedClient.GetStylistId());
                model.Add("client", selectedClient);
                model.Add("stylist", SelectedStylist);
                return(View["client.cshtml", model]);
            };

            Get["stylist/update/{id}"] = parameters => {
                Stylist model = Stylist.Find(parameters.id);
                return(View["stylist_update.cshtml", model]);
            };

            Patch["stylist/update/{id}"] = parameters => {
                Stylist selectedStylist = Stylist.Find(parameters.id);

                string stylistName = Request.Form["stylist-name"];
                selectedStylist.Update(stylistName);
                Stylist updatedStylist = Stylist.Find(parameters.id);
                return(View["success.cshtml", updatedStylist]);
            };

            Get["/stylist/{id}/new_client"] = parameters =>
            {
                Stylist selectedStylist = Stylist.Find(parameters.id);
                return(View["client_to_stylist_form.cshtml.cshtml", selectedStylist]);
            };

            Post["/stylist/{id}/new_client"] = parameters => {
                Dictionary <string, object> model = new Dictionary <string, object> ();
                Stylist selectedStylist           = Stylist.Find(parameters.id);

                string clientName      = Request.Form["client-name"];
                int    clientStylistId = selectedStylist.GetId();

                Client newClient = new Client(clientName, clientStylistId);
                newClient.Save();
                model.Add("client", newClient);
                model.Add("stylist", selectedStylist);
                return(View["success.cshtml", model]);
            };

            Get["/client/update/{id}"] = parameters => {
                Dictionary <string, object> model = new Dictionary <string, object> ();
                Client  selectedClient            = Client.Find(parameters.id);
                Stylist selectedStylist           = Stylist.Find(selectedClient.GetStylistId());
                model.Add("client", selectedClient);
                model.Add("all stylists", Stylist.GetAll());
                return(View["client_update.cshtml", model]);
            };

            Patch["/client/update/{id}"] = parameters => {
                Dictionary <string, object> model = new Dictionary <string, object> ();
                Client selectedClient             = Client.Find(parameters.id);

                string clientName      = Request.Form["client-name"];
                int    clientStylistId = int.Parse(Request.Form["client-stylist-id"]);

                selectedClient.Update(clientName, clientStylistId);
                Client  updatedClient   = Client.Find(parameters.id);
                Stylist SelectedStylist = Stylist.Find(updatedClient.GetStylistId());

                model.Add("client", updatedClient);
                model.Add("stylist", SelectedStylist);
                return(View["success.cshtml", model]);
            };

            Get["/stylist/delete/{id}"] = parameters => {
                Stylist selectedStylist = Stylist.Find(parameters.id);
                return(View["cleared.cshtml", selectedStylist]);
            };

            Delete["/stylist/delete/{id}"] = parameters => {
                Stylist selectedStylist = Stylist.Find(parameters.id);
                selectedStylist.Delete();
                return(View["success.cshtml"]);
            };

            Get["/client/delete/{id}"] = parameters => {
                Dictionary <string, object> model = new Dictionary <string, object> ();
                Client  selectedClient            = Client.Find(parameters.id);
                Stylist SelectedStylist           = Stylist.Find(selectedClient.GetStylistId());

                model.Add("client", selectedClient);
                model.Add("stylist", SelectedStylist);
                return(View["cleared.cshtml", model]);
            };

            Delete["/client/delete/{id}"] = parameters => {
                Client selectedClient = Client.Find(parameters.id);
                selectedClient.Delete();
                return(View["success.cshtml"]);
            };
        }
コード例 #30
0
 public HomeModule()
 {
     Get["/"] = _ => {
         List <Stylist> allStylists = Stylist.GetAll();
         return(View["index.cshtml", allStylists]);
     };
     Get["/stylist/add"] = _ => {
         return(View["new-stylist-form.cshtml"]);
     };
     Post["/stylist/add"] = _ => {
         Stylist newStylist = new Stylist(Request.Form["stylistName"]);
         newStylist.Save();
         List <Stylist> allStylists = Stylist.GetAll();
         return(View["index.cshtml", allStylists]);
     };
     Get["/stylist/{id}"] = parameters => {
         Stylist currentStylist = Stylist.Find(parameters.id);
         return(View["stylist.cshtml", currentStylist]);
     };
     Get["/client/add"] = _ => {
         List <Stylist> allStylists = Stylist.GetAll();
         return(View["new-client-form.cshtml", allStylists]);
     };
     Post["/client/add"] = _ => {
         Client newClient = new Client(Request.Form["clientName"], Request.Form["clientStylistId"]);
         newClient.Save();
         List <Stylist> allStylists = Stylist.GetAll();
         return(View["index.cshtml", allStylists]);
     };
     Get["/client/{id}"] = parameters => {
         Client currentClient = Client.Find(parameters.id);
         return(View["client.cshtml", currentClient]);
     };
     Get["/stylist/edit/{id}"] = parameters => {
         Stylist currentStylist = Stylist.Find(parameters.id);
         return(View["edit-stylist-form.cshtml", currentStylist]);
     };
     Patch["/stylist/edit/{id}"] = parameters => {
         Stylist currentStylist = Stylist.Find(parameters.id);
         currentStylist.Edit(Request.Form["stylistName"]);
         return(View["stylist.cshtml", currentStylist]);
     };
     Get["/client/edit/{id}"] = parameters => {
         Client currentClient = Client.Find(parameters.id);
         return(View["edit-client-form.cshtml", currentClient]);
     };
     Patch["/client/edit/{id}"] = parameters => {
         Client currentClient = Client.Find(parameters.id);
         currentClient.Edit(Request.Form["clientName"], currentClient.GetStylistId());
         return(View["client.cshtml", currentClient]);
     };
     Delete["/stylist/delete/{id}"] = parameters => {
         Stylist currentStylist = Stylist.Find(parameters.id);
         currentStylist.Delete();
         List <Stylist> allStylists = Stylist.GetAll();
         return(View["index.cshtml", allStylists]);
     };
     Delete["/client/delete/{id}"] = parameters => {
         Client  currentClient  = Client.Find(parameters.id);
         Stylist currentStylist = Stylist.Find(currentClient.GetStylistId());
         currentClient.Delete();
         return(View["stylist.cshtml", currentStylist]);
     };
 }
コード例 #31
0
ファイル: HomeModule.cs プロジェクト: Rouz1130/hair-salon
        public Homemodule()
        {
            Get["/"] = _ => {
            List<Stylist> AllStylists = Stylist.GetAll();
            return View["index.cshtml", AllStylists];
              };

              Get["/clients"] = _ => {
            List<Client> AllClients = Client.GetAll();
            return View["clients.cshtml", AllClients];
              };

              Get["/stylists"] = _ => {
            List<Stylist> AllStylists = Stylist.GetAll();
            return View["stylists.cshtml", AllStylists];
              };

              Get["/stylists/new"] = _ => {
            return View["stylists_form.cshtml"];
              };

              Post["/stylists/new"] = _ => {
            Stylist newStylist = new Stylist(Request.Form["stylist-name"]);
            newStylist.Save();
            return View["success.cshtml"];
              };

              Get["/clients/new"] = _ => {
            List<Stylist> AllStylists = Stylist.GetAll();
            return View["clients_form.cshtml", AllStylists];
              };
              Post["/clients/new"] = _ => {
            Client newClient = new Client(Request.Form["client-name"], Request.Form["stylist-id"]);
            newClient.Save();
            return View["success.cshtml"];
              };

              Post["/clients/delete"] = _ => {
            Client.DeleteAll();
            return View["cleared.cshtml"];
              };

              Get["/stylists/{id}"] = parameters => {
            Dictionary<string, object> model = new Dictionary<string, object>();
            var SelectedStylist = Stylist.Find(parameters.id);
            var StylistClients = SelectedStylist.GetClients();
            model.Add("stylist", SelectedStylist);
            model.Add("clients", StylistClients);
            return View["stylist.cshtml", model];
              };

              Get["stylist/edit/{id}"] = parameters => {
            Stylist SelectedStylist = Stylist.Find(parameters.id);
            return View["stylist_edit.cshtml", SelectedStylist];
              };

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

              Get["stylist/delete/{id}"] = parameters => {
            Stylist SelectedStylist = Stylist.Find(parameters.id);
            return View["stylist_delete.cshtml", SelectedStylist];
              };
              Delete["stylist/delete/{id}"] = parameters => {
            Stylist SelectedStylist = Stylist.Find(parameters.id);
            SelectedStylist.Delete();
            return View["success.cshtml"];
              };
        }
コード例 #32
0
        public HomeModule()
        {
            Get["/"] = _ => {
                return(View["index.cshtml"]);
            }; //homepage

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

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

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

            Get["/salons/new"] = _ => {
                return(View["add_salon.cshtml"]);
            }; //navigates to form to add new salon

            Post["/salons/new"] = _ => {
                Salon newSalon = new Salon(Request.Form["salon-name"], Request.Form["salon-about"]);
                newSalon.Save();
                List <Salon> allSalons = Salon.GetAll();
                return(View["salons.cshtml", allSalons]);
            }; //posts from form adding new salon, returns list of all salons

            Get["/stylists/new"] = _ => {
                List <Salon> AllSalons = Salon.GetAll();
                return(View["add_stylist.cshtml", AllSalons]);
            }; //navigates to form to add new stylist

            Post["/stylists/new"] = _ => {
                Stylist newStylist = new Stylist(Request.Form["stylist-name"], Request.Form["stylist-bio"], Request.Form["salon-id"]);
                newStylist.Save();
                List <Stylist> allStylists = Stylist.GetAll();
                return(View["stylists.cshtml", allStylists]);
            }; //posts from form adding new stylist, returns list of all stylists

            Get["/clients/new"] = _ => {
                List <Stylist> AllStylists = Stylist.GetAll();
                return(View["add_client.cshtml", AllStylists]);
            }; //navigates to form to add new client

            Post["/clients/new"] = _ => {
                Client newClient = new Client(Request.Form["client-name"], Request.Form["stylist-id"]);
                newClient.Save();
                List <Client> allClients = Client.GetAll();
                return(View["clients.cshtml", allClients]);
            }; //posts from form adding new client, returns list of all clients

            Get["/salons/{id}"] = parameters => {
                Dictionary <string, object> model = new Dictionary <string, object>();
                Salon          SelectedSalon      = Salon.Find(parameters.id);
                List <Stylist> SalonStylists      = SelectedSalon.GetStylists();
                model.Add("salon", SelectedSalon);
                model.Add("stylists", SalonStylists);
                return(View["salon.cshtml", model]);
            }; //retrieves individual salon pages

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

            Patch["/salon/{id}/edit"] = parameters => {
                Dictionary <string, object> model = new Dictionary <string, object>();
                Salon SelectedSalon = Salon.Find(parameters.id);
                SelectedSalon.Update(Request.Form["salon-name"], Request.Form["salon-about"]);
                List <Stylist> SalonStylists = SelectedSalon.GetStylists();
                model.Add("salon", SelectedSalon);
                model.Add("stylists", SalonStylists);
                return(View["salon.cshtml", model]);
            }; //returns edited salon page

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

            Delete["salon/{id}/delete"] = parameters => {
                Salon SelectedSalon = Salon.Find(parameters.id);
                SelectedSalon.Delete();
                List <Salon> allSalons = Salon.GetAll();
                return(View["salons.cshtml", allSalons]);
            }; //returns confirmation of deleted salon

            Get["/stylists/{id}"] = parameters => {
                Stylist       SelectedStylist     = Stylist.Find(parameters.id);
                List <Client> stylistClients      = SelectedStylist.GetClients();
                Dictionary <string, object> model = new Dictionary <string, object>();
                model.Add("stylist", SelectedStylist);
                model.Add("clients", stylistClients);
                return(View["stylist.cshtml", model]);
            }; //retrieves individual stylist pages

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

            Patch["/stylist/{id}/edit"] = parameters => {
                Dictionary <string, object> model = new Dictionary <string, object>();
                Stylist SelectedStylist           = Stylist.Find(parameters.id);
                SelectedStylist.Update(Request.Form["stylist-name"], Request.Form["stylist-bio"]);
                List <Client> StylistClients = SelectedStylist.GetClients();
                model.Add("stylist", SelectedStylist);
                model.Add("clients", StylistClients);
                return(View["stylist.cshtml", model]);
            }; //returns edited stylist page

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

            Delete["stylist/{id}/delete"] = parameters => {
                Stylist SelectedStylist = Stylist.Find(parameters.id);
                SelectedStylist.Delete();
                List <Stylist> allStylists = Stylist.GetAll();
                return(View["stylists.cshtml", allStylists]);
            }; //returns confirmation of deleted stylist

            Get["/clients/{id}"] = parameters => {
                Client SelectedClient             = Client.Find(parameters.id);
                Dictionary <string, object> model = new Dictionary <string, object>();
                model.Add("client", SelectedClient);
                return(View["client.cshtml", model]);
            }; //retrieves individual client pages

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

            Patch["/client/{id}/edit"] = parameters => {
                Dictionary <string, object> model = new Dictionary <string, object>();
                Client SelectedClient             = Client.Find(parameters.id);
                SelectedClient.UpdateString(Request.Form["client-name"]);
                model.Add("client", SelectedClient);
                return(View["client.cshtml", model]);
            }; //returns edited client page

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

            Delete["client/{id}/delete"] = parameters => {
                Client SelectedClient = Client.Find(parameters.id);
                SelectedClient.Delete();
                List <Client> allClients = Client.GetAll();
                return(View["clients.cshtml", allClients]);
            }; //returns confirmation of deleted client
        }
コード例 #33
0
 public HomeModule()
 {
     Get["/"] = _ => {
         List <Stylist> allStylists = Stylist.GetAll();
         return(View["index.cshtml", allStylists]);
     };
     Get["/stylist/new"] = _ => {
         return(View["stylist_form.cshtml"]);
     };
     Post["/stylist/add"] = _ => {
         Stylist newStylist = new Stylist(Request.Form["stylist-name"]);
         newStylist.Save();
         List <Stylist> allStylists = Stylist.GetAll();
         return(View["index.cshtml", allStylists]);
     };
     Get["/client/{id}"] = parameter => {
         Stylist stylistClients = Stylist.Find(parameter.id);
         return(View["stylist.cshtml", stylistClients]);
     };
     Post["/client/add/{id}"] = parameter => {
         Client newClient = new Client(Request.Form["client-name"], parameter.id);
         newClient.Save();
         Stylist stylistClients = Stylist.Find(parameter.id);
         return(View["stylist.cshtml", stylistClients]);
     };
     Get["/stylist/edit/{id}"] = parameter => {
         Stylist selectedStylist = Stylist.Find(parameter.id);
         return(View["stylist_edit.cshtml", selectedStylist]);
     };
     Patch["/stylist/edit/{id}"] = parameter => {
         Stylist selectedStylist = Stylist.Find(parameter.id);
         selectedStylist.Update(Request.Form["new-stylist-name"]);
         List <Stylist> allStylists = Stylist.GetAll();
         return(View["index.cshtml", allStylists]);
     };
     Get["/stylist/delete/{id}"] = parameter => {
         Stylist selectedStylist = Stylist.Find(parameter.id);
         return(View["stylist_delete.cshtml", selectedStylist]);
     };
     Delete["/stylist/delete/{id}"] = parameter => {
         Stylist selectedStylist = Stylist.Find(parameter.id);
         selectedStylist.Delete();
         List <Stylist> allStylists = Stylist.GetAll();
         return(View["index.cshtml", allStylists]);
     };
     Get["/clients"] = _ => {
         List <Client> allClients = Client.GetAll();
         return(View["clients.cshtml", allClients]);
     };
     Get["/clients/{id}"] = parameter => {
         Client selectedClient = Client.Find(parameter.id);
         return(View["client.cshtml", selectedClient]);
     };
     Get["/client/edit/{id}"] = parameter => {
         Client selectedClient = Client.Find(parameter.id);
         return(View["client_edit.cshtml", selectedClient]);
     };
     Patch["/client/edit/{id}"] = parameter => {
         Client  selectedClient = Client.Find(parameter.id);
         Stylist currentStylist = Stylist.Find(selectedClient.GetStylistId());
         selectedClient.Update(Request.Form["new-client-name"], currentStylist.GetId());
         List <Client> allClients = Client.GetAll();
         return(View["clients.cshtml", allClients]);
     };
 }
コード例 #34
0
ファイル: HomeModule.cs プロジェクト: bryantwang1/hair_salon
        public HomeModule()
        {
            Get["/"] = _ => {
                List <Stylist> allStylists = Stylist.GetAll();
                return(View["index.cshtml", allStylists]);
            };

            Get["/clients"] = _ => {
                List <Client> allClients = Client.GetAll();
                return(View["clients.cshtml", allClients]);
            };

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

            Post["/stylists/new"] = _ => {
                string stylistName        = Request.Form["stylist-name"];
                string stylistPhone       = Request.Form["stylist-phone"];
                string stylistDescription = Request.Form["stylist-description"];

                Stylist newStylist = new Stylist(stylistName, stylistPhone, stylistDescription);
                newStylist.Save();
                return(View["stylist_added.cshtml", newStylist]);
            };

            Get["/clients/new"] = _ => {
                List <Stylist> allStylists = Stylist.GetAll();
                return(View["client_form.cshtml", allStylists]);
            };

            Post["/clients/new"] = _ => {
                Dictionary <string, object> model = new Dictionary <string, object> ();
                string clientName        = Request.Form["client-name"];
                string clientDescription = Request.Form["client-description"];
                int    clientStylistId   = int.Parse(Request.Form["client-stylist-id"]);

                Client newClient = new Client(clientName, clientDescription, clientStylistId);
                newClient.Save();

                Stylist assignedStylist = Stylist.Find(clientStylistId);
                model.Add("client", newClient);
                model.Add("stylist", assignedStylist);
                return(View["client_added.cshtml", model]);
            };

            Get["/stylist/{id}"] = parameters => {
                Stylist selectedStylist = Stylist.Find(parameters.id);
                return(View["stylist.cshtml", selectedStylist]);
            };

            Get["/client/{id}"] = parameters => {
                Dictionary <string, object> model = new Dictionary <string, object> ();
                Client  selectedClient            = Client.Find(parameters.id);
                Stylist selectedStylist           = Stylist.Find(selectedClient.GetStylistId());
                model.Add("client", selectedClient);
                model.Add("stylist", selectedStylist);
                return(View["client.cshtml", model]);
            };

            Get["/stylist/{id}/new_client"] = parameters => {
                Stylist selectedStylist = Stylist.Find(parameters.id);
                return(View["specific_stylist_client_form.cshtml", selectedStylist]);
            };

            Post["/stylist/{id}/new_client"] = parameters => {
                Dictionary <string, object> model = new Dictionary <string, object> ();
                Stylist selectedStylist           = Stylist.Find(parameters.id);

                string clientName        = Request.Form["client-name"];
                string clientDescription = Request.Form["client-description"];
                int    clientStylistId   = selectedStylist.GetId();

                Client newClient = new Client(clientName, clientDescription, clientStylistId);
                newClient.Save();
                model.Add("client", newClient);
                model.Add("stylist", selectedStylist);
                return(View["client_added.cshtml", model]);
            };

            Get["/stylist/edit/{id}"] = parameters => {
                Stylist selectedStylist = Stylist.Find(parameters.id);
                return(View["stylist_edit.cshtml", selectedStylist]);
            };

            Patch["/stylist/edit/{id}"] = parameters => {
                Stylist selectedStylist = Stylist.Find(parameters.id);

                string stylistName        = Request.Form["stylist-name"];
                string stylistPhone       = Request.Form["stylist-phone"];
                string stylistDescription = Request.Form["stylist-description"];

                selectedStylist.Update(stylistName, stylistPhone, stylistDescription);
                Stylist updatedStylist = Stylist.Find(parameters.id);
                return(View["stylist_edited.cshtml", updatedStylist]);
            };

            Get["/client/edit/{id}"] = parameters => {
                Dictionary <string, object> model = new Dictionary <string, object> ();
                Client  selectedClient            = Client.Find(parameters.id);
                Stylist selectedStylist           = Stylist.Find(selectedClient.GetStylistId());
                model.Add("client", selectedClient);
                model.Add("all stylists", Stylist.GetAll());
                return(View["client_edit.cshtml", model]);
            };

            Patch["/client/edit/{id}"] = parameters => {
                Dictionary <string, object> model = new Dictionary <string, object> ();
                Client selectedClient             = Client.Find(parameters.id);

                string clientName        = Request.Form["client-name"];
                string clientDescription = Request.Form["client-description"];
                int    clientStylistId   = int.Parse(Request.Form["client-stylist-id"]);

                selectedClient.Update(clientName, clientDescription, clientStylistId);
                Client  updatedClient   = Client.Find(parameters.id);
                Stylist selectedStylist = Stylist.Find(updatedClient.GetStylistId());

                model.Add("client", updatedClient);
                model.Add("stylist", selectedStylist);
                return(View["client_edited.cshtml", model]);
            };

            Get["/stylist/delete/{id}"] = parameters => {
                Stylist selectedStylist = Stylist.Find(parameters.id);
                return(View["stylist_delete.cshtml", selectedStylist]);
            };

            Delete["/stylist/delete/{id}"] = parameters => {
                Stylist selectedStylist = Stylist.Find(parameters.id);
                selectedStylist.Delete();
                return(View["entry_deleted.cshtml"]);
            };

            Get["/client/delete/{id}"] = parameters => {
                Dictionary <string, object> model = new Dictionary <string, object> ();
                Client  selectedClient            = Client.Find(parameters.id);
                Stylist selectedStylist           = Stylist.Find(selectedClient.GetStylistId());

                model.Add("client", selectedClient);
                model.Add("stylist", selectedStylist);
                return(View["client_delete.cshtml", model]);
            };

            Delete["/client/delete/{id}"] = parameters => {
                Client selectedClient = Client.Find(parameters.id);
                selectedClient.Delete();
                return(View["entry_deleted.cshtml"]);
            };
        }
コード例 #35
0
 public HomeModule()
 {
     Get["/"] = _ => {
         List <Stylist> allStylists = Stylist.GetAll();
         return(View["index.cshtml", allStylists]);
     };
     Get["/stylists/new"] = _ => {
         Dictionary <string, object> model = new Dictionary <string, object> {
         };
         string formType = Request.Query["form-type"];
         model.Add("form-type", formType);
         return(View["form.cshtml", model]);
     };
     Get["/stylists/{id}"] = parameters => {
         Dictionary <string, object> model = new Dictionary <string, object> {
         };
         Stylist       selectedStylist     = Stylist.Find(parameters.id);
         List <Client> selectedClients     = selectedStylist.GetClients();
         model.Add("clients", selectedClients);
         model.Add("stylist", selectedStylist);
         return(View["stylist.cshtml", model]);
     };
     Get["/stylists/{id}/clients/new"] = parameters => {
         Dictionary <string, object> model = new Dictionary <string, object> {
         };
         Stylist selectedStylist           = Stylist.Find(parameters.id);
         string  formType = Request.Query["form-type"];
         model.Add("form-type", formType);
         model.Add("stylist", selectedStylist);
         return(View["form.cshtml", model]);
     };
     Get["/stylists/delete"] = _ => {
         return(View["stylists_delete_confirmation.cshtml"]);
     };
     Get["/stylists/{stylistId}/clients/{clientId}/edit"] = parameters => {
         Dictionary <string, object> model = new Dictionary <string, object> {
         };
         string  formType        = Request.Query["form-type"];
         Stylist selectedStylist = Stylist.Find(parameters.stylistId);
         Client  selectedClient  = Client.Find(parameters.clientId);
         model.Add("form-type", formType);
         model.Add("client", selectedClient);
         model.Add("stylist", selectedStylist);
         return(View["form.cshtml", model]);
     };
     Get["/stylists/{stylistId}/edit"] = parameters => {
         Dictionary <string, object> model = new Dictionary <string, object> {
         };
         string  formType        = Request.Query["form-type"];
         Stylist selectedStylist = Stylist.Find(parameters.stylistId);
         model.Add("form-type", formType);
         model.Add("stylist", selectedStylist);
         return(View["form.cshtml", model]);
     };
     Get["/stylists/search"] = _ => {
         Dictionary <string, object> model = new Dictionary <string, object> {
         };
         string         searchQuery        = Request.Query["search-query"];
         List <Stylist> matches            = Stylist.SearchByName(searchQuery);
         model.Add("search-query", searchQuery);
         model.Add("matches", matches);
         return(View["results.cshtml", model]);
     };
     Post["/"] = _ => {
         Stylist newStylist = new Stylist(Request.Form["stylist-name"], Request.Form["stylist-telephone"]);
         newStylist.Save();
         List <Stylist> allStylists = Stylist.GetAll();
         return(View["index.cshtml", allStylists]);
     };
     Post["/stylists/{id}/clients/new"] = parameters => {
         Dictionary <string, object> model = new Dictionary <string, object> {
         };
         Client newClient = new Client(Request.Form["client-name"], Request.Form["client-telephone"], parameters.id);
         newClient.Save();
         Stylist       selectedStylist = Stylist.Find(parameters.id);
         List <Client> selectedClients = selectedStylist.GetClients();
         model.Add("clients", selectedClients);
         model.Add("stylist", selectedStylist);
         return(View["stylist.cshtml", model]);
     };
     Delete["/"] = _ => {
         Stylist.DeleteAll();
         List <Stylist> allStylists = Stylist.GetAll();
         return(View["index.cshtml", allStylists]);
     };
     Delete["/stylist/{id}/deleted"] = parameters => {
         Stylist selectedStylist = Stylist.Find(parameters.id);
         selectedStylist.Delete();
         List <Stylist> allStylists = Stylist.GetAll();
         return(View["index.cshtml", allStylists]);
     };
     Delete["/stylist/{id}/clients/deleted"] = parameters => {
         Dictionary <string, object> model = new Dictionary <string, object> {
         };
         Stylist selectedStylist           = Stylist.Find(parameters.id);
         selectedStylist.DeleteClients();
         List <Client> selectedClients = selectedStylist.GetClients();
         model.Add("clients", selectedClients);
         model.Add("stylist", selectedStylist);
         return(View["stylist.cshtml", model]);
     };
     Delete["/stylists/{stylistId}/clients/{clientId}/delete"] = parameters => {
         Dictionary <string, object> model = new Dictionary <string, object> {
         };
         Client  toDelete        = Client.Find(parameters.clientId);
         Stylist selectedStylist = Stylist.Find(parameters.stylistId);
         selectedStylist.DeleteClient(toDelete);
         List <Client> selectedClients = selectedStylist.GetClients();
         model.Add("clients", selectedClients);
         model.Add("stylist", selectedStylist);
         return(View["stylist.cshtml", model]);
     };
     Patch["/stylists/{stylistId}/clients/{clientId}/edit"] = parameters => {
         Dictionary <string, object> model = new Dictionary <string, object> {
         };
         Stylist selectedStylist           = Stylist.Find(parameters.stylistId);
         Client  selectedClient            = Client.Find(parameters.clientId);
         selectedClient.Update(Request.Form["client-name"], Request.Form["client-telephone"]);
         List <Client> selectedClients = selectedStylist.GetClients();
         model.Add("clients", selectedClients);
         model.Add("stylist", selectedStylist);
         return(View["stylist.cshtml", model]);
     };
     Patch["/stylists/{stylistId}/edit"] = parameters => {
         Dictionary <string, object> model = new Dictionary <string, object> {
         };
         Stylist selectedStylist           = Stylist.Find(parameters.stylistId);
         selectedStylist.Update(Request.Form["stylist-name"], Request.Form["stylist-telephone"]);
         List <Client> selectedClients = selectedStylist.GetClients();
         model.Add("clients", selectedClients);
         model.Add("stylist", selectedStylist);
         return(View["stylist.cshtml", model]);
     };
 }
コード例 #36
0
ファイル: StylistsTest.cs プロジェクト: Rouz1130/hair-salon
        public void Test6_Update_StylistToDatabase()
        {
            string name = "Maggy";
              Stylist testStylist = new Stylist(name);
              testStylist.Save();
              string newName = "Steve";

              testStylist.Update(newName);

              string result = testStylist.GetName();

              Assert.Equal(newName, result);
        }
コード例 #37
0
        public HomeModule()
        {
            Get["/"] = _ => {
                return(View["index.cshtml"]);
            };
            Get["/Stylist"] = _ => {
                List <Stylist> AllStylist = Stylist.GetAll();
                return(View["Stylist.cshtml", AllStylist]);
            };
            Get["/Stylist/{id}"] = parameters => {
                List <Client> newClients = Client.FindList(parameters.id);
                Client        newClient  = new Client("FAKE", parameters.id);
                newClients.Add(newClient);
                return(View["StylistClients.cshtml", newClients]);
            };
            Get["/Stylist/Client/All"] = _ => {
                List <Client> allClients = Client.GetAll();
                return(View["AllClients.cshtml", allClients]);
            };
            Get["/Stylist/new"] = _ => {
                return(View["newStylist.cshtml"]);
            };

            Post["/Stylist/Success"] = _ => {
                Stylist newStylist = new Stylist(Request.Form["name"]);
                newStylist.Save();
                return(View["Success.cshtml"]);
            };

            Get["/Client/new/{id}"] = parameters => {
                List <Client> ClientList = Client.FindList(parameters.id);
                Client        newClient  = new Client("FAKE", parameters.id);
                ClientList.Add(newClient);
                List <Stylist> allStylist = Stylist.GetAll();
                return(View["newClient.cshtml", ClientList]);
            };

            Post["/Client/Success"] = _ => {
                Client newClient = new Client(Request.Form["name"], Request.Form["stylist"]);
                newClient.Save();
                return(View["Success.cshtml"]);
            };

            Delete["/deleted"] = _ => {
                Stylist.DeleteAll();
                List <Stylist> allStylist = Stylist.GetAll();
                return(View["Stylist.cshtml", allStylist]);
            };

            Delete["/deleted/{id}"] = parameters => {
                Client newClient = Client.Find(parameters.id);
                Client.Find(parameters.id).Delete();
                List <Stylist> allStylist = Stylist.GetAll();
                return(View["Stylist.cshtml", allStylist]);
            };

            Delete["/clients/deleted"] = _ => {
                Client.DeleteAll();
                return(View["Success.cshtml"]);
            };

            Get["/change/{id}"] = parameters => {
                Client newClient = Client.Find(parameters.id);
                return(View["change.cshtml", newClient]);
            };

            Patch["/change/success/{id}"] = parameters => {
                Client newClient = Client.Find(parameters.id);
                string Name      = Request.Form["changeName"];
                newClient.Update(Name);
                // newClient.Save();
                Client TestClient = Client.Find(newClient.GetId());
                Console.WriteLine(TestClient.GetName());
                return(View["index.cshtml"]);
            };
        }
コード例 #38
0
        public HomeModule()
        {
            Get["/"] = _ => {
                List <Stylist> AllStylists = Stylist.GetAll();
                return(View["index.cshtml", AllStylists]);
            };

            Get["/stylists"] = _ => {
                List <Stylist> AllStylists = Stylist.GetAll();
                return(View["stylists.cshtml", AllStylists]);
            };

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

            Post["/stylists/new"] = _ => {
                Stylist newStylist = new Stylist(Request.Form["stylist-name"], Request.Form["stylist-availability"], Request.Form["stylist-services"]);
                newStylist.Save();
                return(View["success.cshtml"]);
            };

            Get["/stylists/{id}"] = parameters => {
                Dictionary <string, object> model = new Dictionary <string, object>();
                var SelectedStylist = Stylist.Find(parameters.id);
                var StylistClients  = SelectedStylist.GetClients();
                model.Add("stylist", SelectedStylist);
                model.Add("clients", StylistClients);
                return(View["stylist.cshtml", model]);
            };

            Get["/stylist/edit/{id}"] = parameters => {
                Stylist SelectedStylist = Stylist.Find(parameters.id);
                return(View["stylist_edit.cshtml", SelectedStylist]);
            };

            Patch["stylist/edit/{id}"] = parameters => {
                Stylist SelectedStylist = Stylist.Find(parameters.id);
                SelectedStylist.Update(Request.Form["stylist-availability"], Request.Form["stylist-services"]);
                return(View["success.cshtml"]);
            };

            Delete["/stylist/delete/{id}"] = parameters => {
                Stylist.Delete(parameters.id);
                return(View["deleted.cshtml"]);
            };

            Delete["/stylists/delete"] = _ => {
                Stylist.DeleteAll();
                return(View["success.cshtml"]);
            };

            Get["/clients"] = _ => {
                List <Client> AllClients = Client.GetAll();
                return(View["clients.cshtml", AllClients]);
            };

            Get["/clients/new"] = _ => {
                List <Stylist> AllStylists = Stylist.GetAll();
                return(View["clients_form.cshtml", AllStylists]);
            };

            Post["/clients/new"] = _ => {
                Client newClient = new Client(Request.Form["client-name"], Request.Form["stylist-id"], Request.Form["client-appointment-day"], Request.Form["client-appointment-time"]);
                newClient.Save();
                return(View["success.cshtml"]);
            };

            Get["/clients/{id}"] = parameters => {
                Client SelectedClient = Client.Find(parameters.id);
                return(View["client.cshtml", SelectedClient]);
            };

            Get["/client/edit/{id}"] = parameters => {
                Client SelectedClient = Client.Find(parameters.id);
                return(View["client_edit.cshtml", SelectedClient]);
            };

            Patch["client/edit/{id}"] = parameters => {
                Client SelectedClient = Client.Find(parameters.id);
                SelectedClient.Update(Request.Form["client-appointment-day"], Request.Form["client-appointment-time"]);
                return(View["success.cshtml"]);
            };

            Delete["/client/delete/{id}"] = parameters => {
                Client.Delete(parameters.id);
                return(View["deleted.cshtml"]);
            };

            Delete["/clients/delete"] = _ => {
                Client.DeleteAll();
                return(View["success.cshtml"]);
            };
        }
コード例 #39
0
 public HomeModule()
 {
     Get["/"] = _ => {
         List <Stylist> allStylists = Stylist.GetAll();
         return(View["home.cshtml", allStylists]);
     };
     Get["/stylists"] = _ => {
         List <Stylist> allStylists = Stylist.GetAll();
         return(View["stylists.cshtml", allStylists]);
     };
     Get["/clients"] = _ => {
         List <Client> allClients = Client.GetAll();
         return(View["clients.cshtml", allClients]);
     };
     Get["/stylists/new"] = _ => {
         return(View["stylist_add.cshtml"]);
     };
     Get["/clients/new"] = _ => {
         List <Stylist> allStylists = Stylist.GetAll();
         return(View["client_add.cshtml", allStylists]);
     };
     Post["/stylists/new"] = _ => {
         Stylist newStylist = new Stylist(Request.Form["stylist-firstName"], Request.Form["stylist-lastName"], Request.Form["stylist-specialty"]);
         newStylist.Save();
         return(View["success.cshtml"]);
     };
     Post["/clients/new"] = _ => {
         Client newClient = new Client(Request.Form["client-firstName"], Request.Form["stylist-id"]);
         newClient.Save();
         return(View["success.cshtml"]);
     };
     Get["/stylists/{id}"] = parameters => {
         Dictionary <string, object> zomgHair = new Dictionary <string, object>();
         var selectedStylist = Stylist.Find(parameters.id);
         var stylistClients  = selectedStylist.GetClients();
         zomgHair.Add("stylist", selectedStylist);
         zomgHair.Add("clients", stylistClients);
         return(View["stylist.cshtml", zomgHair]);
     };
     Get["/clients/{id}"] = parameters => {
         Dictionary <string, object> zomgFixMyHair = new Dictionary <string, object>();
         var selectedClient = Client.Find(parameters.id);
         zomgFixMyHair.Add("client", selectedClient);
         return(View["client.cshtml", zomgFixMyHair]);
     };
     Get["/clients/{id}/edit"] = parameters => {
         Dictionary <string, object> zomgEdit = new Dictionary <string, object>();
         Client selectedClient = Client.Find(parameters.id);
         zomgEdit.Add("selectedClient", selectedClient);
         return(View["client_edit.cshtml", zomgEdit]);
     };
     Get["/clients/{id}/delete"] = _ => {
         return(View["success.cshtml"]);
     };
     Patch["/clients/{id}/edit"] = parameters => {
         Client selectedClient = Client.Find(parameters.id);
         string newName        = Request.Form["client-name"];
         selectedClient.Update(newName);
         return(View["success.cshtml"]);
     };
     Delete["/clients/{id}/delete"] = parameters => {
         Client selectedClient = Client.Find(parameters.id);
         selectedClient.Delete();
         return(View["success.cshtml"]);
     };
 }
コード例 #40
0
 public HomeModule()
 {
     Get["/"] = _ => {
         List <Stylist> allStylists = Stylist.GetAll();
         return(View["index.cshtml", allStylists]);
     };
     Get["/clients"] = _ => {
         List <Client> AllClients = Client.GetAll();
         return(View["clients.cshtml", AllClients]);
     };
     Get["/stylists"] = _ => {
         List <Stylist> AllStylists = Stylist.GetAll();
         return(View["stylists.cshtml", AllStylists]);
     };
     Get["/stylists/new"] = _ => {
         return(View["stylists_form.cshtml"]);
     };
     Get["/clients/new"] = _ => {
         List <Stylist> AllStylists = Stylist.GetAll();
         return(View["clients_form.cshtml", AllStylists]);
     };
     Post["/stylists/new"] = _ => {
         Stylist newStylist = new Stylist(Request.Form["name"], Request.Form["location"]);
         newStylist.Save();
         return(View["index.cshtml"]);
     };
     Post["/clients/new"] = _ => {
         Client newClient = new Client(Request.Form["name"], Request.Form["stylist-id"]);
         newClient.Save();
         return(View["index.cshtml"]);
     };
     Get["/stylists/{id}"] = parameters => {
         Dictionary <string, object> model = new Dictionary <string, object>();
         var selectedStylist = Stylist.Find(parameters.id);
         var stylistClients  = selectedStylist.GetClients();
         model.Add("stylist", selectedStylist);
         model.Add("clients", stylistClients);
         return(View["stylist.cshtml", model]);
     };
     Get["/stylists/edit/{id}"] = parameters => {
         Stylist selectedStylist = Stylist.Find(parameters.id);
         return(View["stylist_edit.cshtml", selectedStylist]);
     };
     Patch["/stylists/edit/{id}"] = parameters => {
         Stylist SelectedStylist = Stylist.Find(parameters.id);
         string  newName         = Request.Form["name"];
         string  newLocation     = Request.Form["location"];
         SelectedStylist.Update(newName, newLocation);
         return(View["index.cshtml"]);
     };
     Get["/stylists/delete/{id}"] = parameters => {
         Stylist SelectedStylist = Stylist.Find(parameters.id);
         return(View["stylist_delete.cshtml", SelectedStylist]);
     };
     Delete["/stylists/delete/{id}"] = parameters => {
         Stylist SelectedStylist = Stylist.Find(parameters.id);
         SelectedStylist.Delete();
         return(View["index.cshtml"]);
     };
     Get["/clients/delete/{id}"] = parameters => {
         return(View["client_delete.cshtml"]);
     };
     Delete["/clients/delete/{id}"] = parameters => {
         Client selectedClient = Client.Find(parameters.id);
         selectedClient.Delete();
         return(View["index.cshtml"]);
     };
 }
コード例 #41
0
        public HomeModule()
        {
            Get["/"] = _ => {
                List <Stylist> AllLists = Stylist.GetAll();
                return(View["index.cshtml"]);
            };
            Get["/stylists"] = _ => {
                var AllStylists = Stylist.GetAll();
                return(View["stylists.cshtml", AllStylists]);
            };
            Get["/clients"] = _ => {
                var AllClients = Client.GetAll();
                return(View ["clients.cshtml", AllClients]);
            };
            Get["/stylists/new"] = _ => {
                return(View["stylists_form.cshtml"]);
            };
            Post["/stylists/new"] = _ => {
                Stylist newStylist = new Stylist(Request.Form["name"], Request.Form["availability"]);
                newStylist.Save();
                List <Stylist> allStylists = Stylist.GetAll();
                return(View["success.cshtml"]);
            };
            Get["/client/new"] = _ => {
                List <Stylist> AllStylists = Stylist.GetAll();
                return(View["clients_form.cshtml", AllStylists]);
            };

            Post["/clients/new"] = _ => {
                Client newClient = new Client(Request.Form["client-name"], Request.Form["stylist"]);
                newClient.Save();
                return(View["success.cshtml"]);
            };
            Post["/clients/delete"] = _ => {
                Client.DeleteAll();
                return(View["cleared.cshtml"]);
            };
            Get["/stylists/{id}"] = parameters => {
                Dictionary <string, object> model = new Dictionary <string, object>();
                var selectedStylist    = Stylist.Find(parameters.id);
                var stylistClientsList = selectedStylist.GetClients();
                model.Add("stylist", selectedStylist);
                model.Add("clients", stylistClientsList);
                return(View["stylist.cshtml", model]);
            };
            Get["/stylist/edit/{id}"] = parameters => {
                Stylist selectedStylist = Stylist.Find(parameters.id);
                return(View["stylist_edit.cshtml", selectedStylist]);
            };
            Patch["/stylist/edit/{id}"] = parameters => {
                Stylist selectedStylist = Stylist.Find(parameters.id);
                selectedStylist.UpdateName(Request.Form["stylist-name"]);
                return(View["success.cshtml"]);
            };
            Get["/client/edit/{id}"] = parameters => {
                Client selectedClient = Client.Find(parameters.id);
                return(View["client_edit.cshtml", selectedClient]);
            };
            Patch["/client/edit/{id}"] = parameters => {
                Client selectedClient = Client.Find(parameters.id);
                selectedClient.UpdateName(Request.Form["client-name"]);
                return(View["success.cshtml"]);
            };
            Get["/stylist/delete/{id}"] = parameters => {
                Stylist selectedStylist = Stylist.Find(parameters.id);
                return(View["/stylist_delete.cshtml", selectedStylist]);
            };
            Delete["stylist/delete/{id}"] = parameters => {
                Stylist selectedStylist = Stylist.Find(parameters.id);
                selectedStylist.Delete();
                return(View["success.cshtml"]);
            };
            Get["/client/delete/{id}"] = parameters => {
                Client selectedClient = Client.Find(parameters.id);
                return(View["/client_delete.cshtml", selectedClient]);
            };
            Delete["/client/delete/{id}"] = parameters => {
                Client selectedClient = Client.Find(parameters.id);
                selectedClient.Delete();
                return(View["success.cshtml"]);
            };
        }