Пример #1
0
 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);
 }
Пример #2
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);
        }
Пример #3
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);
        }
Пример #4
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);
        }
Пример #5
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"]);
                }
            };
        }
Пример #6
0
        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);
        }
Пример #7
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"]);
     };
 }
Пример #8
0
        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]);
            };
        }
Пример #9
0
        public HomeModule()
        {
            Get["/"] = _ => {
                List <Stylist> AllStylist = Stylist.GetAll();
                return(View["index.cshtml", AllStylist]);
            };
            Get["/clients"] = _ => {
                List <Client> AllClient = Client.GetAll();
                return(View["clients.cshtml", AllClient]);
            };
            Get["/stylists"] = _ => {
                List <Stylist> AllStylist = Stylist.GetAll();
                return(View["stylists.cshtml", AllStylist]);
            };
            Get["/stylists/new"] = _ => {
                return(View["stylists_form.cshtml"]);
            };
            Post["stylists/new"] = _ => {
                Stylist        newStylist = new Stylist(Request.Form["stylist-name"]);
                List <Stylist> AllStylist = Stylist.GetAll();
                newStylist.Save();
                return(View["success.cshtml", AllStylist]);
            };
            Get["/clients/new"] = _ => {
                List <Stylist> AllClient = Stylist.GetAll();
                return(View["clients_form.cshtml", AllClient]);
            };
            Post["/clients/new"] = _ => {
                Client        newClient = new Client(Request.Form["client-name"], Request.Form["stylist-id"]);
                List <Client> AllClient = Client.GetAll();
                newClient.Save();
                return(View["clients.cshtml", AllClient]);
            };
            Post["/clients/clear"] = _ => {
                Client.DeleteAll();
                return(View["cleared.cshtml"]);
            };
            Get["/clients/{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["clients.cshtml", model]);
            };
            Get["/client/edit/{id}"] = parameters => {
                Dictionary <string, object> model = new Dictionary <string, object>();
                Stylist       SelectedStylist     = Stylist.Find(parameters.id);
                List <Client> StylistClients      = SelectedStylist.GetClients();
                model.Add("client", SelectedStylist);
                model.Add("clients", StylistClients);
                return(View["client_edit.cshtml", model]);
            };
            Patch["/client/edit/{id}"] = parameters => {
                Stylist SelectedStylist = Stylist.Find(parameters.id);
                SelectedStylist.Update(Request.Form["client-name"]);

                return(View["success.cshtml"]);
            };
            Get["/client/delete/{id}"] = parameters => {
                Dictionary <string, object> model = new Dictionary <string, object>();
                Client SelectedClient             = Client.Find(parameters.id);
                model.Add("client", SelectedClient);
                return(View["client_delete.cshtml", model]);
            };
            Delete["/client/delete/{id}"] = parameters => {
                Dictionary <string, object> model = new Dictionary <string, object>();
                Client SelectedClient             = Client.Find(parameters.id);
                SelectedClient.Delete();
                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 => {
                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["stylist_edit.cshtml", model]);
            };
            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 => {
                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["stylist_delete.cshtml", model]);
            };
            Delete["/stylist/delete/{id}"] = parameters => {
                Stylist SelectedStylist = Stylist.Find(parameters.id);
                SelectedStylist.Delete();
                return(View["success.cshtml"]);
            };
        }
Пример #10
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["stylist_add.cshtml"]);
     };
     Post["/stylists/new"] = _ => {
         Stylist newStylist = new Stylist(Request.Form["stylist-name"], Request.Form["stylist-specialty"]);
         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();
         // var clientFeedback = selectedClient.GetFeedback();
         model.Add("stylist", selectedStylist);
         model.Add("clients", stylistClients);
         // model.Add("feedback", clientFeedback);
         return(View["stylist.cshtml", model]);
     };
     Get["/clients"] = _ => {
         List <Client> allClients = Client.GetAll();
         return(View["clients.cshtml", allClients]);
     };
     Get["/clients/new"] = _ => {
         List <Stylist> allStylists = Stylist.GetAll();
         return(View["client_add.cshtml", allStylists]);
     };
     Post["/clients/new"] = _ => {
         Client newClient = new Client(Request.Form["client-name"], Request.Form["client-details"], Request.Form["stylist-id"]);
         newClient.Save();
         return(View["success.cshtml"]);
     };
     Get["/clients/{id}"] = parameters => {
         Dictionary <string, object> model = new Dictionary <string, object>();
         var selectedClient = Client.Find(parameters.id);
         // var clientStylist = selectedClient.GetStylist();
         model.Add("client", selectedClient);
         // model.Add("stylist", clientStylist);
         return(View["client.cshtml", model]);
     };
     Get["clients/{id}/edit"] = parameters => {
         Dictionary <string, object> model = new Dictionary <string, object>();
         Client selectedClient             = Client.Find(parameters.id);
         model.Add("selectedClient", selectedClient);
         return(View["client_edit.cshtml", model]);
     };
     Patch["/clients/{id}/edit"] = parameters => {
         Client selectedClient = Client.Find(parameters.id);
         string newClientName  = Request.Form["client-name"];
         string newDetails     = Request.Form["client-details"];
         if (newClientName == "" && newDetails != "")
         {
             selectedClient.UpdateDetails(newDetails);
         }
         else if (newClientName != "" && newDetails == "")
         {
             selectedClient.UpdateClientName(newClientName);
         }
         else
         {
             selectedClient.UpdateDetails(newDetails);
             selectedClient.UpdateClientName(newClientName);
         }
         return(View["success.cshtml"]);
     };
     Get["stylists/{id}/delete"] = parameters => {
         Stylist selectedStylist = Stylist.Find(parameters.id);
         return(View["stylist_delete.cshtml", selectedStylist]);
     };
     Delete["stylists/{id}/delete"] = parameters => {
         Stylist selectedStylist = Stylist.Find(parameters.id);
         selectedStylist.Delete();
         return(View["success.cshtml"]);
     };
     Get["clients/{id}/delete"] = parameters => {
         Client selectedClient = Client.Find(parameters.id);
         return(View["client_delete.cshtml", selectedClient]);
     };
     Delete["clients/{id}/delete"] = parameters => {
         Client selectedClient = Client.Find(parameters.id);
         selectedClient.Delete();
         return(View["success.cshtml"]);
     };
 }