Example #1
0
        public void Test_Find_FindsStylistsInDatabase()
        {
            //Arrange
            Stylists testStylists = new Stylists("Jacob");

            testStylists.Save();
            //Act
            Stylists foundStylists = Stylists.Find(testStylists.GetId());

            //Assert
            Assert.Equal(testStylists, foundStylists);
        }
Example #2
0
        public void Test_Update_UpdatesStylistsInDatabase()
        {
            //Arrange
            string   name         = "Nick";
            Stylists testStylists = new Stylists(name);

            testStylists.Save();
            string newName = "Jacob";

            //Act
            testStylists.Update("Jacob");
            string result = testStylists.GetName();

            //Assert
            Assert.Equal(newName, result);
        }
Example #3
0
        public void Test_Save_SaveStylistToDatabase()
        {
            //Arrange
            Stylists testStylists = new Stylists("Jacob");

            testStylists.Save();

            //Act
            List <Stylists> result   = Stylists.GetAll();
            List <Stylists> testList = new List <Stylists> {
                testStylists
            };

            //Assert
            Assert.Equal(testList, result);
        }
Example #4
0
        public void Test_GetClients_RetrieveAllClientsWithinStylists()
        {
            //Arrange
            Stylists testStylists = new Stylists("Jacob");

            testStylists.Save();

            Clients firstClients = new Clients("Susan", testStylists.GetId());

            firstClients.Save();
            Clients secondClients = new Clients("Emma", testStylists.GetId());

            secondClients.Save();

            //Act
            List <Clients> testClientsList = new List <Clients> {
                firstClients, secondClients
            };
            List <Clients> resultClientsList = testStylists.GetClients();

            //Assert
            Assert.Equal(testClientsList, resultClientsList);
        }
Example #5
0
        public void Test_Delete_DeleteStylistFromDatabase()
        {
            //Arrange
            string   name1        = "Gary";
            Stylists testStylist1 = new Stylists(name1);

            testStylist1.Save();

            string   name2        = "Wallace";
            Stylists testStylist2 = new Stylists(name2);

            testStylist2.Save();

            Clients client1 = new Clients("Susan", testStylist1.GetId());

            client1.Save();
            Clients client2 = new Clients("Emma", testStylist2.GetId());

            client2.Save();

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

            List <Clients> resultClients = Clients.GetAll();
            List <Clients> clientsList   = new List <Clients> {
                client2
            };

            //Assert
            Assert.Equal(testStylists, resultStylists);
            Assert.Equal(clientsList, resultClients);
        }
Example #6
0
 public HomeModule()
 {
     Get["/"]         = _ => View["index.cshtml"];
     Get["/stylists"] = _ => {
         List <Stylists> AllStylists = Stylists.GetAll();
         return(View["stylists.cshtml", AllStylists]);
     };
     Get["/clients"] = _ => {
         List <Clients> AllClients = Clients.GetAll();
         return(View["clients.cshtml", AllClients]);
     };
     Get["/clients/new"] = _ => {
         List <Stylists> AllStylists = Stylists.GetAll();
         return(View["/add_client.cshtml", AllStylists]);
     };
     Get["/stylists/new"] = _ => {
         return(View["/add_stylist.cshtml"]);
     };
     Post["/clients"] = _ => {
         Dictionary <string, object> model = new Dictionary <string, object>();
         Clients newClients      = new Clients(Request.Form["client"], Request.Form["stylist_id"]);
         var     selectedStylist = Stylists.Find(newClients.GetStylistId());
         newClients.Save();
         model.Add("stylist", selectedStylist);
         model.Add("client", newClients);
         return(View["client_added.cshtml", model]);
     };
     Post["/stylists"] = _ => {
         Stylists newStylists = new Stylists(Request.Form["name"]);
         newStylists.Save();
         return(View["stylist_added.cshtml", newStylists]);
     };
     Get["/clients/{id}"] = parameters => {
         Dictionary <string, object> model = new Dictionary <string, object>();
         var selectedClient  = Clients.Find(parameters.id);
         var selectedStylist = Stylists.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 = Stylists.Find(parameters.id);
         var ClientStylist   = selectedStylist.GetClients();
         model.Add("stylist", selectedStylist);
         model.Add("clients", ClientStylist);
         return(View["stylist.cshtml", model]);
     };
     Post["/stylists/cleared"] = _ => {
         Clients.DeleteAll();
         Stylists.DeleteAll();
         return(View["cleared.cshtml"]);
     };
     Post["/clients/cleared"] = _ => {
         Clients.DeleteAll();
         return(View["cleared.cshtml"]);
     };
     Get["/stylists/edit/{id}"] = parameters => {
         Stylists SelectedStylist = Stylists.Find(parameters.id);
         return(View["stylist_edit.cshtml", SelectedStylist]);
     };
     Patch["/stylists/edit/{id}"] = parameters => {
         Stylists SelectedStylists = Stylists.Find(parameters.id);
         SelectedStylists.Update(Request.Form["name"]);
         return(View["success.cshtml"]);
     };
     Get["/clients/edit/{id}"] = parameters => {
         Clients selectedClient = Clients.Find(parameters.id);
         return(View["client_edit.cshtml", selectedClient]);
     };
     Patch["/clients/edit/{id}"] = parameters => {
         Clients SelectedClient = Clients.Find(parameters.id);
         SelectedClient.Update(Request.Form["name"]);
         return(View["success.cshtml"]);
     };
     Get["stylists/delete/{id}"] = parameters => {
         Stylists SelectedStylist = Stylists.Find(parameters.id);
         return(View["stylist_delete.cshtml", SelectedStylist]);
     };
     Delete["stylists/delete/{id}"] = parameters => {
         Stylists SelectedStylist = Stylists.Find(parameters.id);
         SelectedStylist.Delete();
         return(View["success.cshtml"]);
     };
     Get["clients/delete/{id}"] = parameters => {
         Clients SelectedClient = Clients.Find(parameters.id);
         return(View["client_delete.cshtml", SelectedClient]);
     };
     Delete["clients/delete/{id}"] = parameters => {
         Clients SelectedClient = Clients.Find(parameters.id);
         SelectedClient.Delete();
         return(View["success.cshtml"]);
     };
 }