Esempio n. 1
0
        public void Test5_Find_NewStylistInDatabase()
        {
            Stylist testStylist = new Stylist ("Maggy");
              testStylist.Save();

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

              Assert.Equal(testStylist, foundStylist);
        }
Esempio n. 2
0
        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);
        }
Esempio n. 3
0
        public override bool Equals(System.Object otherStylist)
        {
            if (!(otherStylist is Stylist))
            {
                return(false);
            }
            else
            {
                Stylist newStylist        = (Stylist)otherStylist;
                bool    idEquality        = this.GetId() == newStylist.GetId();
                bool    nameEquality      = this.GetName() == newStylist.GetName();
                bool    contactEquality   = this.GetContact() == newStylist.GetContact();
                bool    photolinkEquality = this.GetPhotolink() == newStylist.GetPhotolink();

                return(idEquality && nameEquality);
            }
        }
Esempio n. 4
0
        public void update_ChangeStylistName_StylistwithNewName()
        {
            //Arrange
            Stylist updateStylist = new Stylist("Ally Berry");

            updateStylist.Save();
            string newName = "Veronica Moore";

            //Act
            updateStylist.Update(newName);

            Stylist result      = Stylist.GetAll()[0];
            int     comparingId = result.GetId();
            Stylist testStylist = new Stylist(newName, comparingId);

            //Assert
            Assert.Equal(testStylist, result);
        }
Esempio n. 5
0
        public void Test_Delete_DeletesStylistInDatabase()
        {
            //Arrange
            Stylist testStylist1 = new Stylist("Lisa", "MTuWTh", "Color and Style");
            Stylist testStylist2 = new Stylist("Kim", "TuWFSa", "Cuts Only");


            //Act
            testStylist1.Save();
            testStylist2.Save();
            Stylist.Delete(testStylist1.GetId());
            List <Stylist> result   = Stylist.GetAll();
            List <Stylist> testList = new List <Stylist> {
                testStylist2
            };

            //Assert
            Assert.Equal(testList, result);
        }
Esempio n. 6
0
        public void Test_GetAllClients_GetClientsForThisStylist()
        {
            //Arrange, Act
            Stylist testStylist = new Stylist("Dave the Stylish Stylist");

            testStylist.Save();

            Client client = new Client("Ricky Bobby is a client", testStylist.GetId());

            client.Save();

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

            //Assert
            Assert.Equal(testClientList, resultClientList);
        }
Esempio n. 7
0
        public void T4_Save_GetId_DoesSaveIdToStylist()
        {
            //Arrange
            Stylist testStylist = new Stylist("Amy Zee");

            testStylist.Save();

            //Act
            Stylist savedStylist = Stylist.GetAll()[0];

            int testId = testStylist.GetId();

            Console.WriteLine(testId);
            int resultId = savedStylist.GetId();

            Console.WriteLine(resultId);

            //Assert
            Assert.Equal(testId, resultId);
        }
Esempio n. 8
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);
        }
Esempio n. 9
0
        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);
        }
Esempio n. 10
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);
        }
Esempio n. 11
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);
        }
Esempio n. 12
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);
        }
Esempio n. 13
0
        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);
        }
Esempio n. 14
0
        public void Test_Update_ReturnsTrueIfSalonIdsAreTheSame()
        {
            //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("Harry Cutter", "a great stylist", 3, firstTestStylist.GetId());

            //Act
            secondTestStylist.Update(firstTestStylist.GetSalonId());
            //Assert
            Assert.Equal(firstTestStylist, secondTestStylist);
        }
Esempio n. 15
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]);
     };
 }
Esempio n. 16
0
        public void Test_GetClients_RetrieveAllClientsForStylist()
        {
            //Arrange
            Stylist testStylist = new Stylist("Bishop", "701-013-2008", "*****@*****.**");

            testStylist.Save();
            Client firstClient = new Client("Ellen Ripley", "098-765-4321", "*****@*****.**", testStylist.GetId());

            firstClient.Save();
            Client secondClient = new Client("Corporal Hicks", "487-098-0756", "*****@*****.**", testStylist.GetId());

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

            //Assert
            Assert.Equal(testClientList, resultClientList);
        }
Esempio n. 17
0
        public void Test_Delete_DeletesStylistAndAssociatedClientsFromDatabase()
        {
            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();

            stylist2.Delete();
            List <Stylist> expectedStylists = new List <Stylist> {
                stylist1
            };
            List <Stylist> stylistResults = Stylist.GetAll();

            List <Client> expectedClients = new List <Client> {
                client2
            };
            List <Client> clientResults = Client.GetAll();

            Assert.Equal(expectedStylists, stylistResults);
            Assert.Equal(expectedClients, clientResults);
        }
Esempio n. 18
0
        public void Test_Delete_StylistFromDatabase()
        {
            //Arrange
            Stylist testStylist1 = new Stylist("Bojack", "123-456-7890", "*****@*****.**");

            testStylist1.Save();
            Stylist testStylist2 = new Stylist("Todd", "098-765-4321", "*****@*****.**");

            testStylist2.Save();
            Client testClient1 = new Client("Sleepy Gary", "123-450-9877", "*****@*****.**", testStylist1.GetId());

            testClient1.Save();
            Client testClient2 = new Client("Mr. Beauregard", "555-867-5309", "*****@*****.**", testStylist2.GetId());

            testClient2.Save();
            //Act
            testStylist1.Delete();
            List <Stylist> resultStylist = Stylist.GetAll();
            List <Stylist> testStylist   = new List <Stylist> {
                testStylist2
            };
            List <Client> resultClients  = Client.GetAll();
            List <Client> testClientList = new List <Client> {
                testClient2
            };

            //Assert
            Assert.Equal(testStylist, resultStylist);
            Assert.Equal(testClientList, resultClients);
        }
Esempio n. 19
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/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"]);
            };
        }
Esempio n. 20
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"]);
            };
        }
Esempio n. 21
0
        public void Test_Update_ReturnsTrueIfStylistInfoIsTheSame()
        {
            //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(), firstTestStylist.GetId());

            //Act
            secondTestStylist.Update("Harry Cutter", "a great stylist");
            //Assert
            Assert.Equal(firstTestStylist, secondTestStylist);
        }
Esempio n. 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"]);
     };
 }