コード例 #1
0
ファイル: ClientTest.cs プロジェクト: yichiang/Hair-Salon
        public void Test4_Save_AssignsIdToObjects()
        {
            Client firstClient = new Client("erere", 13);
              firstClient.Save();
              Client savedClient = Client.GetAll()[0];

              Assert.Equal(firstClient, savedClient);
        }
コード例 #2
0
ファイル: ClientTest.cs プロジェクト: yichiang/Hair-Salon
        public void Test6_Update_ClientInDatabase()
        {
            Client oneClient = new Client("erere", 13);
              oneClient.Save();
              oneClient.Update("q");
              string result = oneClient.GetName();

              Assert.Equal("q", result);
        }
コード例 #3
0
ファイル: ClientTest.cs プロジェクト: yichiang/Hair-Salon
        public void Test3_Save_ClientsToObjects()
        {
            List<Client> saveOneClient = new List<Client>{};
              Client firstClient = new Client("erere", 13);
              saveOneClient.Add(firstClient);
              firstClient.Save();
              List<Client> allClients=Client.GetAll();

              Assert.Equal(saveOneClient,allClients);
        }
コード例 #4
0
ファイル: ClientTest.cs プロジェクト: RubyBe/Salon
 public void FindById_FindsAClientById_ClientFoundById()
 {
     // Arrange
       Client testClient = new Client("Doc Gonzo", "Brush", 1);
       testClient.Save();
       // Act
       Client foundClient = Client.Find(testClient.GetId());
       // Assert
       Assert.Equal(testClient, foundClient);
 }
コード例 #5
0
ファイル: HomeModule.cs プロジェクト: RubyBe/Salon
        public HomeModule()
        {
            Get["/"] = _ =>
              {
            var allStylists = Stylist.GetAll();
            return View["index.cshtml", allStylists];
              };

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

              Get["/stylists/{id}"] = parameters => {
               Dictionary<string, object> model = new Dictionary<string, object>();
               var selectedStylist = Stylist.Find(parameters.id);
               var stylistClients = selectedStylist.GetClients(parameters.id);
               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"];
             };

             Post["/stylist/new"] = _ =>
             {
               Client newClient = new Client(Request.Form["client-name"], Request.Form["client-treatment"], Request.Form["stylist-id"]);
               newClient.Save();
               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"];
             };
        }
コード例 #6
0
ファイル: ClientTest.cs プロジェクト: yichiang/Hair-Salon
        public void Test5_Find_FindsClientInDatabase()
        {
            //Arrange
               Client oneClient = new Client("erere", 13);
               oneClient.Save();

               //Act
               Client foundClient  = Client.Find(oneClient.GetId());
               //Assert
               Assert.Equal(oneClient, foundClient);
        }
コード例 #7
0
ファイル: ClientTest.cs プロジェクト: RubyBe/Salon
 public void Test_Save_AssignsIdToObject()
 {
     // Arrange
       Client testClient = new Client("Doc Gonzo", "Haircut", 1);
       // Act
       testClient.Save();
       Client savedClient = Client.GetAll()[0];
       int result = savedClient.GetId();
       int testId = testClient.GetId();
       // Assert
       Assert.Equal(testId, result);
 }
コード例 #8
0
        public void Test_Client_Given_Id()
        {
            Client testClient = new Client("Conrad", 1);

            testClient.Save();

            Client savedClient = Client.GetAll()[0];

            int result = savedClient.GetId();
            int testId = testClient.GetId();

            Assert.Equal(result, testId);
        }
コード例 #9
0
        public void Test_Find_FindsClientInDatabase()
        {
            //Arrange
            Client testClient = new Client("James", 1);

            testClient.Save();

            //Act
            Client foundClient = Client.Find(testClient.GetId());

            //Assert
            Assert.Equal(testClient, foundClient);
        }
コード例 #10
0
ファイル: ClientTest.cs プロジェクト: moodyan/hair-salon
        [Fact] //Spec 3
        public void Test_Save_ToClientDatabase()
        {
            Client testClient = new Client("Beau Blue", "None", 1);

            testClient.Save();

            List <Client> result   = Client.GetAll();
            List <Client> testList = new List <Client> {
                testClient
            };

            Assert.Equal(testList, result);
        }
コード例 #11
0
        public void T3_Save_SavesToDB()
        {
            Client testClient = new Client("Shaggy", "Dew", 1);

            testClient.Save();

            List <Client> result   = Client.GetAll();
            List <Client> testList = new List <Client> {
                testClient
            };

            Assert.Equal(testList, result);
        }
コード例 #12
0
        public void Test_SaveTo_Database()
        {
            Client testClient = new Client("Conrad", 1);

            testClient.Save();

            List <Client> result   = Client.GetAll();
            List <Client> testList = new List <Client> {
                testClient
            };

            Assert.Equal(result, testList);
        }
コード例 #13
0
        public void Test_UpdatesClient_In_Database()
        {
            string name       = "Dwight";
            Client testClient = new Client(name, 1);

            testClient.Save();

            string newName = "Douglas";

            testClient.Update(newName);
            string result = testClient.GetName();

            Assert.Equal(newName, result);
        }
コード例 #14
0
        public void Test_Update_UpdatesClientInDatabase()
        {
            string name       = "Billy Joe";
            int    id         = 1;
            Client testClient = new Client(name, id);

            testClient.Save();
            string newName = "Billy Joel";

            testClient.Update(newName);
            string result = testClient.GetName();

            Assert.Equal(newName, result);
        }
コード例 #15
0
ファイル: ClientTests.cs プロジェクト: ekillops/cs-salon
        public void Search_FindsResultsBasedOnInputTheory(string searchColumn, string searchValue, int expectedMatches)
        {
            //Arrange
            Client testOne = new Client("Sally Smith", "503-111-2222", 1);
            Client testTwo = new Client("Bob Johnson", "503-333-4567", 2);

            testOne.Save();
            testTwo.Save();
            //Act
            List <Client> matches = Client.SearchByValue(searchColumn, searchValue);

            //Assert
            Assert.Equal(expectedMatches, matches.Count);
        }
コード例 #16
0
ファイル: ClientTest.cs プロジェクト: moodyan/hair-salon
        [Fact] //Spec 6
        public void Test_Update_UpdatesClientDetailsInDatabase()
        {
            string clientName = "Minnie Mouse";
            string details    = "Getting married to Mickey Mouse, practice updo for wedding";
            int    stylistId  = 1;
            Client testClient = new Client(clientName, details, stylistId);

            testClient.Save();
            string newDetails = "Post wedding hair cut. Cut 5 inches off.";

            testClient.UpdateDetails(newDetails);
            string result = testClient.GetDetails();

            Assert.Equal(newDetails, result);
        }
コード例 #17
0
ファイル: StylistsTest.cs プロジェクト: yichiang/Hair-Salon
        public void Test5_GetAllClient_esInStylist_true()
        {
            Stylist myStylist = new Stylist("lo-main");
              myStylist.Save();

              Client firstClient = new Client("Pizza",myStylist.GetId());
              firstClient.Save();
              Client secondClient = new Client("tacos",myStylist.GetId());
              secondClient.Save();

              List<Client> testClientList = new List<Client> {firstClient,secondClient};
              List<Client> resultClientList = myStylist.GetClient();

              Assert.Equal(testClientList, resultClientList);
        }
コード例 #18
0
        public void Test_Save_AssignsIdToObject()
        {
            //Arrange
            Client testClient = new Client("James", 1);

            //Act
            testClient.Save();
            Client savedClient = Client.GetAll()[0];

            int result = savedClient.GetId();
            int testId = testClient.GetId();

            //Assert
            Assert.Equal(testId, result);
        }
コード例 #19
0
        public void Test_Save_SavesToDatabase()
        {
            //Arrange
            Client testClient = new Client("Manny", 1);

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

            //Assert
            Assert.Equal(testList, result);
        }
コード例 #20
0
ファイル: StylistTest.cs プロジェクト: moodyan/hair-salon
        public void Test_Update_UpdatesClientNameInDatabase()
        {
            string clientName = "Minnie Moo";
            string details    = "Getting married to Mickey Mouse, practice updo for wedding";
            int    stylistId  = 1;
            Client testClient = new Client(clientName, details, stylistId);

            testClient.Save();
            string newClientName = "Minnie Mouse";

            testClient.UpdateClientName(newClientName);
            string result = testClient.GetClientName();

            Assert.Equal(newClientName, result);
        }
コード例 #21
0
ファイル: ClientTest.cs プロジェクト: RubyBe/Salon
 public void Test_Delete_DeletesClientFromDatabase()
 {
     // Arrange
       string name = "Yousef";
       Client testClient = new Client(name, "Cuts", 1);
       testClient.Save();
       string name2 = "John";
       Client testClient2 = new Client(name, "Brushes", 1);
       testClient2.Save();
       // Act
       testClient.Delete();
       List<Client> resultClients = Client.GetAll();
       List<Client> testClientList = new List<Client> {testClient2};
       // Assert
       Assert.Equal(testClientList, resultClients);
 }
コード例 #22
0
ファイル: ClientTests.cs プロジェクト: ekillops/cs-salon
        public void Update_ChangesValuesInDatabase_EquivalentObject()
        {
            //Arrange
            Client testClient = new Client("Sally Smith", "503-111-2222", 1);

            testClient.Save();
            Client expectedResult = new Client("Sally Smith", "503-111-2222", 2, testClient.GetId());
            int    targetId       = testClient.GetId();

            //Act
            Client.Update(targetId, "Sally Smith", "503-111-2222", 2);
            Client retrievedClient = Client.Find(targetId);

            //Assert
            Assert.Equal(expectedResult, retrievedClient);
        }
コード例 #23
0
        public void T7_Delete_DeleteClientFromDB()
        {
            Client testClient1 = new Client("Shaggy", "Dew", 1);

            testClient1.Save();
            Client testClient2 = new Client("Lange", "Ponyta", 2);

            testClient2.Save();

            testClient1.Delete();

            List <Client> result      = Client.GetAll();
            List <Client> testClients = new List <Client> {
                testClient2
            };

            Assert.Equal(testClients, result);
        }
コード例 #24
0
        public void Test_Delete_Deletes_Stylist_FromDatabase()
        {
            Client testClient1 = new Client("Dinese", 1);

            testClient1.Save();
            Client testClient2 = new Client("Damian", 2);

            testClient2.Save();

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

            Assert.Equal(testClientList, resultClients);
        }
コード例 #25
0
        public void T6_Update_UpdatesClientInDB()
        {
            Client testClient = new Client("Shaggy", "Dew", 1);

            testClient.Save();

            string newFirst     = "Lange";
            string newLast      = "Ponyta";
            int    newStylistId = 2;

            testClient.Update(newFirst, newLast, newStylistId);

            string result1 = testClient.GetFirstName();
            string result2 = testClient.GetLastName();
            int    result3 = testClient.GetStylistId();

            Assert.Equal(newFirst, result1);
            Assert.Equal(newLast, result2);
            Assert.Equal(newStylistId, result3);
        }
コード例 #26
0
        public void T8_GetClients_RetrievesAllClientsOfStylist()
        {
            Stylist testStylist = new Stylist("Jake", "Shears", "L.5 Master");

            testStylist.Save();

            Client testClient1 = new Client("Shaggy", "Dew", testStylist.GetId());

            testClient1.Save();
            Client testClient2 = new Client("Lange", "Ponyta", testStylist.GetId());

            testClient2.Save();

            List <Client> testClients = new List <Client> {
                testClient1, testClient2
            };
            List <Client> result = testStylist.GetClients();

            Assert.Equal(testClients, result);
        }
コード例 #27
0
ファイル: StylistTest.cs プロジェクト: moodyan/hair-salon
        [Fact] //Spec 4
        public void Test_GetClients_RetrievesAllClientsForStylist()
        {
            Stylist testStylist = new Stylist("Emmylou Earnest", "Men's cuts and short hair styles.");

            testStylist.Save();

            Client firstClient = new Client("Darla Darling", "On her last visit (1/2/2013), we trimmed her hair and touched up her roots with dark drown.", testStylist.GetId());

            firstClient.Save();
            Client secondClient = new Client("Beau Blue", "On his last visit, we shaved his sides and trimmed the top.", testStylist.GetId());

            secondClient.Save();

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

            Assert.Equal(testClientList, resultClientList);
        }
コード例 #28
0
ファイル: StylistsTest.cs プロジェクト: NaruzaL/salon
        public void Test_GetClients_RetrievesAllClientssWithCategory()
        {
            Stylist testStylist = new Stylist("Bob", 1);

            testStylist.Save();

            Client firstClient = new Client("Joe", testStylist.GetId());

            firstClient.Save();
            Client secondClient = new Client("Betsy", testStylist.GetId());

            secondClient.Save();


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

            Assert.Equal(testClientList, resultClientList);
        }
コード例 #29
0
ファイル: StylistTest.cs プロジェクト: YcleptInsan/Salon
        public void Test_GetClients_RetrievesAllClientsWithStylist()
        {
            Stylist testStylist = new Stylist("nancy");

            testStylist.Save();

            Client firstClient = new Client("joe", testStylist.GetId());

            firstClient.Save();
            Client secondClient = new Client("sally", testStylist.GetId());

            secondClient.Save();


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

            Assert.Equal(testClientList, resultClientList);
        }
コード例 #30
0
        public void T9_DeleteStylistClients_DeletesClientIfNoStylist()
        {
            Stylist testStylist = new Stylist("Clementine", "Clips", "L.4 Specialist");

            testStylist.Save();

            Client testClient = new Client("Shaggy", "Dew", testStylist.GetId());

            testClient.Save();

            testStylist.DeleteStylistClients();
            testStylist.Delete();

            List <Client> result      = Client.GetAll();
            int           resultCount = result.Count;
            List <Client> testClients = new List <Client> {
            };
            int testCount             = testClients.Count;

            Assert.Equal(testCount, resultCount);
        }
コード例 #31
0
        public void Test_GetClients_RetrievesAll_Clients_WithStylist()
        {
            Stylist testStylist = new Stylist("Abraham Lincoln");

            testStylist.Save();

            Client firstClient = new Client("Ryan", testStylist.GetId());

            firstClient.Save();
            Client secondClient = new Client("Frank", testStylist.GetId());

            secondClient.Save();


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

            Assert.Equal(testClientList, resultClientList);
        }
コード例 #32
0
        public void Test_Delete_DeletesClientFromDatabase()
        {
            string name1       = "Steve";
            int    id1         = 1;
            Client testClient1 = new Client(name1, id1);

            testClient1.Save();
            string name2       = "Joe";
            int    id2         = 2;
            Client testClient2 = new Client(name2, id2);

            testClient2.Save();

            testClient1.Delete();
            List <Client> resultClient   = Client.GetAll();
            List <Client> testClientList = new List <Client> {
                testClient2
            };

            Assert.Equal(testClientList, resultClient);
        }
コード例 #33
0
ファイル: StylistTest.cs プロジェクト: moodyan/hair-salon
        public void Test_Delete_DeletesStylistFromDatabase()
        {
            //Arrange
            string  stylistName1 = "Emmylou";
            string  specialty1   = "cut and color";
            Stylist testStylist1 = new Stylist(stylistName1, specialty1);

            testStylist1.Save();

            string  stylistName2 = "Betty";
            string  specialty2   = "trim";
            Stylist testStylist2 = new Stylist(stylistName2, specialty2);

            testStylist2.Save();

            Client testClient1 = new Client("Minnie Mouse", "some details", testStylist1.GetId());

            testClient1.Save();
            Client testClient2 = new Client("Darla Darling", "here are some more details", 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);
        }
コード例 #34
0
ファイル: StylistTest.cs プロジェクト: RubyBe/Salon
 public void Test_Delete_DeletesStylistFromDatabase()
 {
     // Arrange
       string name = "Doctor Gonzo";
       Stylist testStylist = new Stylist(name, "Cuts");
       testStylist.Save();
       string name2 = "Mouse";
       Stylist testStylist2 = new Stylist(name2, "Brushes");
       testStylist2.Save();
       Client testClient = new Client("Sid", "Cut", testStylist.GetId());
       testClient.Save();
       Client testClient2 = new Client("Yousef", "Color", testStylist2.GetId());
       testClient2.Save();
       // Act
       testStylist.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);
 }
コード例 #35
0
ファイル: StylistTest.cs プロジェクト: YcleptInsan/Salon
        public void Test_Delete_DeletesStylistFromDatabase()
        {
            //Arrange
            string  name1        = "french";
            Stylist testStylist1 = new Stylist(name1);

            testStylist1.Save();

            string  name2        = "Thai";
            Stylist testStylist2 = new Stylist(name2);

            testStylist2.Save();

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

            testClient1.Save();
            Client testClient2 = new Client("pig ynakers ", 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);
        }
コード例 #36
0
        public void Test_Delete_Deletes_Stylist_FromDatabase()
        {
            //Arrange
            string  name1        = "George";
            Stylist testStylist1 = new Stylist(name1);

            testStylist1.Save();

            string  name2        = "Justin";
            Stylist testStylist2 = new Stylist(name2);

            testStylist2.Save();

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

            testClient1.Save();
            Client testClient2 = new Client("Damian", 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);
        }
コード例 #37
0
ファイル: HomeModule.cs プロジェクト: TalayRuk/salon_db
        public HomeModule()
        {
            Get["/"] = _ => {
                List <Stylist> allStylists = Stylist.GetAll();
                return(View["index.cshtml", allStylists]);
            };

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

            Post["/clients/{id}"] = parameters => {
                Client newClient = new Client(Request.Form["new-client-first"],
                                              Request.Form["new-client-last"],
                                              Request.Form["new-client-stylist-id"]);
                newClient.Save();
                Dictionary <string, object> model = new Dictionary <string, object>();
                Stylist       selectedStylist     = Stylist.Find(parameters.id);
                List <Client> stylistClients      = selectedStylist.GetClients();
                model.Add("stylist", selectedStylist);
                model.Add("clients", stylistClients);
                return(View["clients.cshtml", model]);
            };

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

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

            Patch["/{id}"] = parameters => {
                Stylist selectedStylist = Stylist.Find(parameters.id);
                selectedStylist.Update(Request.Form["update-stylist-expertise"]);
                List <Stylist> allStylists = Stylist.GetAll();
                return(View["index.cshtml", allStylists]);
            };

            Delete["/{id}"] = parameters => {
                Stylist selectedStylist = Stylist.Find(parameters.id);
                selectedStylist.DeleteStylistClients();
                selectedStylist.Delete();
                List <Stylist> allStylists = Stylist.GetAll();
                return(View["index.cshtml", allStylists]);
            };

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

            Patch["/clients/{id}"] = parameters => {
                Dictionary <string, object> model = new Dictionary <string, object>();
                Client selectedClient             = Client.Find(parameters.id);
                selectedClient.Update(Request.Form["update-client-first"],
                                      Request.Form["update-client-last"],
                                      Request.Form["update-client-stylist-id"]);
                Stylist       selectedStylist = Stylist.Find(selectedClient.GetStylistId());
                List <Client> stylistClients  = selectedStylist.GetClients();
                model.Add("stylist", selectedStylist);
                model.Add("clients", stylistClients);
                return(View["clients.cshtml", model]);
            };

            Delete["/clients/{id}"] = parameters => {
                Dictionary <string, object> model = new Dictionary <string, object>();
                Client  selectedClient            = Client.Find(parameters.id);
                Stylist selectedStylist           = Stylist.Find(selectedClient.GetStylistId());
                selectedClient.Delete();
                List <Client> stylistClients = selectedStylist.GetClients();
                model.Add("stylist", selectedStylist);
                model.Add("clients", stylistClients);
                return(View["clients.cshtml", model]);
            };
        }
コード例 #38
0
ファイル: StylistsTest.cs プロジェクト: yichiang/Hair-Salon
        public void Test7_Delete_OneStylist_true()
        {
            Stylist firstStylist = new Stylist("A");
              firstStylist.Save();
              Stylist secondStylist = new Stylist("B");
              secondStylist.Save();

              Client firstStylistClient = new Client("sddsds",firstStylist.GetId());
              firstStylistClient.Save();

              Client secondStylistDsih= new Client("dssdsdds",secondStylist.GetId());
              secondStylistDsih.Save();

              firstStylist.Delete();
              List<Stylist> allStylists = Stylist.GetAll();
              List<Stylist> afterDeleteOneStylist= new List<Stylist> {secondStylist};

              List<Client> resultClient=Client.GetAll();
              List<Client> afterDeleteOneStylistClient= new List<Client> {secondStylistDsih};

              Assert.Equal(afterDeleteOneStylist,allStylists);
              Assert.Equal(afterDeleteOneStylistClient,resultClient);
        }
コード例 #39
0
        public HomeModule()
        {
            Get["/"] = _ => {
                List <Stylist> allStylists = Stylist.GetAll();
                return(View["index.cshtml", allStylists]);
            };

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

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

            Get["/clients/add/{id}"] = parameters => {
                int model = parameters.id;
                return(View["add-client.cshtml", model]);
            };

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

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

            Post["/stylist/delete/{id}"] = parameters =>
            {
                Stylist newStylist = Stylist.Find(parameters.id);
                string  name       = newStylist.GetName();
                Stylist.RemoveAStylist(parameters.id);
                return(View["stylist-deleted.cshtml", name]);
            };

            Post["/client/delete/{id}"] = parameters =>
            {
                Client newClient = Client.Find(parameters.id);
                string name      = newClient.GetName();
                Client.RemoveAClient(parameters.id);
                return(View["client-deleted.cshtml", name]);
            };

            Post["/stylist-added"] = _ =>
            {
                string  name       = Request.Form["name"];
                string  hours      = Request.Form["hours"];
                int     phone      = Request.Form["phone"];
                Stylist newStylist = new Stylist(name, hours, phone);
                newStylist.Save();
                return(View["stylist-added.cshtml", newStylist]);
            };

            Post["/client-added/{id}"] = parameters =>
            {
                string name       = Request.Form["name"];
                string hair_color = Request.Form["hair"];
                int    phone      = Request.Form["phone"];
                Client newClient  = new Client(name, hair_color, phone, parameters.id);
                newClient.Save();
                return(View["client-added.cshtml", newClient]);
            };

            Post["/client-updated/{id}"] = parameters =>
            {
                string name       = Request.Form["name"];
                string hair_color = Request.Form["hair"];
                int    phone      = Request.Form["phone"];
                Client.Update(name, hair_color, phone, parameters.id);
                List <Stylist> allStylists = Stylist.GetAll();
                return(View["index.cshtml", allStylists]);
            };

            Post["/stylist-updated/{id}"] = parameters =>
            {
                string name  = Request.Form["name"];
                string hours = Request.Form["hours"];
                int    phone = Request.Form["phone"];
                Stylist.Update(name, hours, phone, parameters.id);
                List <Stylist> allStylists = Stylist.GetAll();
                return(View["index.cshtml", allStylists]);
            };
        }
コード例 #40
0
ファイル: ClientTest.cs プロジェクト: yichiang/Hair-Salon
        public void Test7_DeleteOneClient_true()
        {
            Client firstClientsClient = new Client("erere",87);
             firstClientsClient.Save();

             Client secondClientsDsih= new Client("erere",56);
             secondClientsDsih.Save();

             firstClientsClient.Delete();

             List<Client> resultClient=Client.GetAll();
             List<Client> afterDeleteOneClientsClient= new List<Client> {secondClientsDsih};

             Assert.Equal(afterDeleteOneClientsClient,resultClient);
        }
コード例 #41
0
ファイル: ClientTest.cs プロジェクト: RubyBe/Salon
 public void Update_UpdatesAClient_ClientUpdated()
 {
     // Arrange
       string name1 = "Doc Gonzo";
       string service1 = "Fur";
       Client testClient1 = new Client(name1, service1, 1);
       testClient1.Save();
       string name2 = "Doctor Gonzo";
       string nameExpected = name2;
       // Act
       testClient1.Update(name2);
       string nameResult = testClient1.GetName();
       // Assert
       Assert.Equal(nameExpected, nameResult);
 }
コード例 #42
0
 public HomeModule()
 {
     Get["/"] = _ => {
         return(View["index.cshtml"]);
     };
     Get["/stylists"] = _ => {
         List <Stylist> allStylists = Stylist.GetAll();
         return(View["stylists.cshtml", allStylists]);
     };
     Get["/stylists/new"] = _ => {
         return(View["stylists_add.cshtml"]);
     };
     Get["/clients/new"] = _ => {
         List <Stylist> allStylists = Stylist.GetAll();
         return(View["clients_add.cshtml", allStylists]);
     };
     Get["/stylist/{id}"] = parameters => {
         var SelectedStylist = Stylist.Find(parameters.id);
         return(View["stylist.cshtml", SelectedStylist]);
     };
     Get["stylist/edit/{id}"] = parameters => {
         Stylist SelectedStylist = Stylist.Find(parameters.id);
         return(View["stylist_edit.cshtml", SelectedStylist]);
     };
     Get["/client-edit/{id}"] = parameters => {
         Client SelectedClient = Client.Find(parameters.id);
         return(View["client_edit.cshtml", SelectedClient]);
     };
     Post["/stylists/new"] = _ => {
         Stylist newStylist = new Stylist(Request.Form["stylist-name"]);
         newStylist.Save();
         return(View["success.cshtml"]);
     };
     Post["/clients/new"] = _ => {
         Client newClient = new Client(Request.Form["client-name"], Request.Form["stylist-id"]);
         newClient.Save();
         return(View["success.cshtml"]);
     };
     Patch["/stylist/edit/{id}"] = parameters => {
         Stylist SelectedStylist = Stylist.Find(parameters.id);
         SelectedStylist.Update(Request.Form["stylist-name"]);
         return(View["success.cshtml"]);
     };
     Patch["/client-edit/{id}"] = parameters => {
         Client SelectedClient = Client.Find(parameters.id);
         SelectedClient.Update(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"]);
     };
 }
コード例 #43
0
ファイル: ClientTest.cs プロジェクト: RubyBe/Salon
 public void Test_Save_SavesToDatabase()
 {
     // Arrange
       Client testClient = new Client("Doc Gonzo", "Brush", 1);
       testClient.Save();
       // Act
       List<Client> listResult = Client.GetAll();
       List<Client> listExpected = new List<Client>{testClient};
       // Assert
       Assert.Equal(listExpected, listResult);
 }
コード例 #44
0
        public HomeModule()
        {
            Get["/"] = _ =>
            {
                return(View["index.cshtml"]);
            };

            // Client Pages
            Get["/clients"] = _ =>
            {
                List <Client> allClients = Client.GetAll();
                return(View["all_clients.cshtml", allClients]);
            };
            Get["/clients/new"] = _ =>
            {
                List <Stylist> allStylists = Stylist.GetAll();
                return(View["new_client_form", allStylists]);
            };
            Get["/clients/{id}"] = parameters =>
            {
                int    clientId     = int.Parse(parameters.id);
                Client targetClient = Client.Find(clientId);
                return(View["client.cshtml", targetClient]);
            };
            Get["/clients/{id}/update"] = parameters =>
            {
                int            clientId                 = int.Parse(parameters.id);
                Client         targetClient             = Client.Find(clientId);
                List <Stylist> allStylists              = Stylist.GetAll();
                Dictionary <string, object> returnModel = new Dictionary <string, object>()
                {
                    { "client", targetClient },
                    { "stylists", allStylists }
                };
                return(View["update_client.cshtml", returnModel]);
            };
            Post["/clients"] = _ =>
            {
                string clientName        = Request.Form["client-name"];
                string clientPhoneNumber = Request.Form["client-phone-number"];
                int    stylistId         = int.Parse(Request.Form["stylist-id"]);
                Client newClient         = new Client(clientName, clientPhoneNumber, stylistId);
                newClient.Save();

                List <Client> allClients = Client.GetAll();
                return(View["all_clients.cshtml", allClients]);
            };
            Patch["/clients"] = _ =>
            {
                int    targetId          = int.Parse(Request.Form["client-id"]);
                string clientName        = Request.Form["client-name"];
                string clientPhoneNumber = Request.Form["client-phone-number"];
                int    stylistId         = int.Parse(Request.Form["stylist-id"]);
                Client.Update(targetId, clientName, clientPhoneNumber, stylistId);

                List <Client> allClients = Client.GetAll();
                return(View["all_clients.cshtml", allClients]);
            };
            Delete["/clients"] = _ =>
            {
                int targetId = int.Parse(Request.Form["client-id"]);
                Client.Delete(targetId);
                List <Client> allClients = Client.GetAll();
                return(View["all_clients.cshtml", allClients]);
            };
            Delete["/clients/clear"] = _ =>
            {
                Client.DeleteAll();
                List <Client> allClients = Client.GetAll();
                return(View["all_clients.cshtml", allClients]);
            };

            //Stylist Pages
            Get["/stylists"] = _ =>
            {
                List <Stylist> allStylists = Stylist.GetAll();
                return(View["all_stylists.cshtml", allStylists]);
            };
            Get["/stylists/new"] = _ =>
            {
                return(View["new_stylist_form"]);
            };
            Get["/stylists/{id}"] = parameters =>
            {
                int     stylistId     = int.Parse(parameters.id);
                Stylist targetStylist = Stylist.Find(stylistId);
                return(View["stylist.cshtml", targetStylist]);
            };
            Get["/stylists/{id}/update"] = parameters =>
            {
                int     stylistId     = int.Parse(parameters.id);
                Stylist targetStylist = Stylist.Find(stylistId);
                return(View["update_stylist.cshtml", targetStylist]);
            };
            Post["/stylists"] = _ =>
            {
                string  stylistName        = Request.Form["stylist-name"];
                string  stylistPhoneNumber = Request.Form["stylist-phone-number"];
                Stylist newStylist         = new Stylist(stylistName, stylistPhoneNumber);
                newStylist.Save();

                List <Stylist> allStylists = Stylist.GetAll();
                return(View["all_stylists.cshtml", allStylists]);
            };
            Patch["/stylists"] = _ =>
            {
                int    targetId           = int.Parse(Request.Form["stylist-id"]);
                string stylistName        = Request.Form["stylist-name"];
                string stylistPhoneNumber = Request.Form["stylist-phone-number"];
                Stylist.Update(targetId, stylistName, stylistPhoneNumber);

                List <Stylist> allStylists = Stylist.GetAll();
                return(View["all_stylists.cshtml", allStylists]);
            };
            Delete["/stylists"] = _ =>
            {
                int targetId = int.Parse(Request.Form["stylist-id"]);
                Stylist.Delete(targetId);
                List <Stylist> allStylists = Stylist.GetAll();
                return(View["all_stylists.cshtml", allStylists]);
            };
            Delete["/stylists/clear"] = _ =>
            {
                Stylist.DeleteAll();
                List <Stylist> allStylists = Stylist.GetAll();
                return(View["all_stylists.cshtml", allStylists]);
            };

            //Search
            Get["/{searchType}/search/{searchBy}"] = parameters =>
            {
                string searchBy    = parameters.searchBy;
                string searchType  = parameters.searchType;
                string searchInput = Request.Query["search-input"];

                if (searchType == "clients")
                {
                    List <Client> searchResults = Client.SearchByValue(searchBy, searchInput);
                    return(View["clients_search.cshtml", searchResults]);
                }
                else if (searchType == "stylists")
                {
                    List <Stylist> searchResults = Stylist.SearchByValue(searchBy, searchInput);
                    return(View["stylists_search.cshtml", searchResults]);
                }
                else
                {
                    return(View["index.cshtml"]);
                }
            };
        }
コード例 #45
0
ファイル: HomeModules.cs プロジェクト: yichiang/Hair-Salon
        public HomeModule()
        {
            Get["/"] = _ => {

              Dictionary<string,object> model=Member.AllData("Welcome To Our Salon!");

              return View["index.cshtml",model];
            };

            Post["/stylist/new"] =_ => {
            Stylist newStylist = new Stylist(Request.Form["new-name"]);
            newStylist.Save();
            string message="Thank you for join us "+Request.Form["new-name"];
            Dictionary<string,object> model=Member.AllData(message);

            return View["allpeople.cshtml",model];
            };

            Post["/client/new"] =_ => {
            Client newClient = new Client(Request.Form["new-name"],Request.Form["stylist-id"]);
              newClient.Save();
            string message="We appreciated your bussiness. "+Request.Form["new-name"];
              Dictionary<string,object> model=Member.AllData(message);

              return View["allpeople.cshtml",model];
            };

            Delete["/delete/stylist/{id}"]=parameters =>{

              Stylist foundStylist = Stylist.Find(parameters.id);
              string message="You Suscessfully Delete "+foundStylist.GetName();
              foundStylist.Delete();

              Dictionary<string,object> model=Member.AllData(message);
              return View["allpeople.cshtml",model];
            };

            Patch["/edit/stylist/{id}"]=parameters =>{

              Stylist foundStylist = Stylist.Find(parameters.id);
              string message="You Suscessfully Change Name from"+
              foundStylist.GetName()+" to "+
              Request.Form["edit-stylist-name"];

              foundStylist.Update(Request.Form["edit-stylist-name"]);
              Dictionary<string,object> model=Member.AllData(message);

              return View["allpeople.cshtml",model];
            };

            Delete["/delete/client/{id}"]=parameters =>{

              Client foundClient = Client.Find(parameters.id);
              string message="You Suscessfully Delete "+foundClient.GetName();
              foundClient.Delete();

              Dictionary<string,object> model=Member.AllData(message);
              return View["allpeople.cshtml",model];
            };

            Patch["/edit/client/{id}"]=parameters =>{

              Client foundClient = Client.Find(parameters.id);
              string message="You Suscessfully Change Name from"+
              foundClient.GetName()+" to "+
              Request.Form["edit-client-name"];

              foundClient.Update(Request.Form["edit-client-name"]);
              Dictionary<string,object> model=Member.AllData(message);

              return View["allpeople.cshtml",model];
            };

            Get["/Client/{id}"]=parameters =>{
              Stylist foundStylist = Stylist.Find(parameters.id);
              List<Client> allMyClients=foundStylist.GetClient();
            Dictionary<string,object> model= new Dictionary<string,object>{};
            model.Add("stylist",foundStylist);
            model.Add("client",allMyClients);
            return View["client.cshtml",model];
            };
            Get["/delete-all"]=_=>{
              return View["confirmation.cshtml"];
            };
            Post["/delete/confirmation"]=_=>{
              string message=" You enter wrong password, and thus you cannont delete anything.";

              if(Request.Form["confirm-delete"]=="delete-all-clients"&&Request.Form["user-password"]=="123")
              {
            Client.DeleteAll();
             message=Request.Form["userName"]+", You deleted all client data";
              }else if(Request.Form["confirm-delete"]=="delete-all"&&Request.Form["user-password"]=="123")
              {
             message=Request.Form["userName"]+", You deleted all data";
            Client.DeleteAll();
            Stylist.DeleteAll();
              }
              Dictionary<string,object> model=Member.AllData(message);
              return View["allpeople.cshtml",model];

            };
        }