Beispiel #1
0
        public HomeModule()
        {
            Get["/"] = _ => {
                List <Stylist> allStylists = Stylist.GetAll();
                return(View["index.cshtml", allStylists]);
            };

            Get["/stylist/add"] = _ => View["stylist_form.cshtml"];

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

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

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

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

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

            Patch["client/edit/{id}"] = parameters => {
                Client SelectedClient = Client.Find(parameters.id);
                SelectedClient.Update(Request.Form["clientName"]);
                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"]);
            };
        }
Beispiel #2
0
        public void Test_Find_FindsClientInDatabase()
        {
            Client testClient = new Client("James", 1);

            testClient.Save();
            Client foundClient = Client.Find(testClient.GetId());

            Assert.Equal(testClient, foundClient);
        }
Beispiel #3
0
        [Fact] //Spec 4
        public void Test_FindClientInDatabase()
        {
            Client testClient = new Client("Beau Blue", "None", 1);

            testClient.Save();

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

            Assert.Equal(testClient, foundClient);
        }
Beispiel #4
0
        public void Test_ToFind_Client_InDatabase()
        {
            Client testClient = new Client("Conrad", 1);

            testClient.Save();

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

            Assert.Equal(foundClient, testClient);
        }
Beispiel #5
0
        public void T5_Find_FindsClientInDB()
        {
            Client testClient = new Client("Shaggy", "Dew", 1);

            testClient.Save();

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

            Assert.Equal(testClient, foundClient);
        }
Beispiel #6
0
        public void Save_SavesToDataBase_EquivalentObject()
        {
            //Arrange
            Client testClient = new Client("Sally Smith", "503-111-2222", 1);

            //Act
            testClient.Save();
            Client retrievedClient = Client.Find(testClient.GetId());

            //Assert
            Assert.Equal(testClient, retrievedClient);
        }
Beispiel #7
0
        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);
        }
Beispiel #8
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"]);
                }
            };
        }
Beispiel #9
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"]);
     };
 }
Beispiel #10
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]);
            };
        }
Beispiel #11
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]);
            };
        }
Beispiel #12
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"]);
     };
 }