Ejemplo n.º 1
0
        public void Test_GetClients()
        {
            //Arrange
              Stylist item = new Stylist("Sherri", "M-W-F", "Clients love her.");
              item.Save();
              Client a = new Client("Janet", item.id, "She's a handful.");
              a.Save();

              //Act
              List<Client> clients = item.GetClients();

              //Assert
              Assert.Equal(clients[0], a);
        }
Ejemplo n.º 2
0
        public ActionResult StylistDetail(int id)
        {
            Dictionary <string, object> model = new Dictionary <string, object>();
            Stylist selectedStylist           = Stylist.Find(id);

            List <Client> stylistClients = selectedStylist.GetClients();

            List <Client> allClients = Client.GetAll();

            model.Add("stylist", selectedStylist);
            model.Add("stylistClients", stylistClients);
            model.Add("allClients", allClients);

            return(View(model));
        }
        public void Test_IfGetAllAlsoReturnsClients_True()
        {
            Stylist newStylist = new Stylist("Beth Jones");

            newStylist.Save();
            Client        newClientOne = new Client("Joe Klein", newStylist.GetId());
            Client        newClientTwo = new Client("Arnold Weber", newStylist.GetId());
            List <Client> allClients   = new List <Client> {
                newClientOne, newClientTwo
            };

            newClientOne.Save();
            newClientTwo.Save();
            List <Client> returnClients = newStylist.GetClients();

            Assert.Equal(allClients, returnClients);
        }
Ejemplo n.º 4
0
        public void Test7_GetClientsInStylist()
        {
            Stylist testStylist = new Stylist("StylistName");

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

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

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

            Assert.Equal(testClientList, resultClientList);
        }
Ejemplo n.º 5
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);
        }
Ejemplo n.º 6
0
        public void Test_GetClients_RetrievesAllClientsWithStylist()
        {
            Stylist newStylist = new Stylist("Frieda", "MWF", 1);

            newStylist.Save();
            Client firstClient = new Client("Mrs. C", newStylist.Id, 1);

            firstClient.Save();
            Client secondClient = new Client("Mr. X", newStylist.Id, 1);

            secondClient.Save();

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

            Assert.Equal(testClientList, resultClientList);
        }
Ejemplo n.º 7
0
        public void Test_GetClients_RetrievesAllClientsByStylist()
        {
            Stylist testStylist = new Stylist("Jenny", "Portland");

            testStylist.Save();
            Client firstClient = new Client("Susan", "Portland", testStylist.GetId());

            firstClient.Save();
            Client secondClient = new Client("Sally", "Oregon City", testStylist.GetId());

            secondClient.Save();

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

            Assert.Equal(testClientList, resultClientList);
        }
Ejemplo n.º 8
0
        public void Test_GetClients_RetrievesAllClientsWithStylist()
        {
            Stylist testStylist = new Stylist("Lisa", "MTuWTh", "Color and Style");

            testStylist.Save();

            Client firstClient = new Client("Susie", testStylist.GetId(), "Monday", "11:30");

            firstClient.Save();
            Client secondClient = new Client("Andrew", testStylist.GetId(), "Monday", "11:30");

            secondClient.Save();

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

            Assert.Equal(testClientList, resultClientList);
        }
Ejemplo n.º 9
0
        public void Test_GetClients_RetrievesAllClientsWithStylist()
        {
            Stylist testStylist = new Stylist("Chet", "Manly", "The StrongMan Do");

            testStylist.Save();

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

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

            secondClient.Save();

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

            Assert.Equal(testClientList, resultClientList);
        }
Ejemplo n.º 10
0
        public void TestStylist_GetClients_GetsClientsbyStylist()
        {
            Stylist testStylist = new Stylist("AmyRose", "Pearl");

            testStylist.Save();

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

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

            secondClient.Save();


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

            Assert.Equal(testList, resultList);
        }
Ejemplo n.º 11
0
        public void TestStylist_GetClients_GetsClientsByStylist()
        {
            Stylist newStylist = new Stylist("Jessica", 5);

            newStylist.Save();

            Client client1 = new Client("Rebecca", newStylist.GetId());

            client1.Save();
            Client client2 = new Client("Tom", newStylist.GetId());

            client2.Save();


            List <Client> controlList = new List <Client> {
                client1, client2
            };
            List <Client> testList = newStylist.GetClients();

            Assert.Equal(controlList, testList);
        }
Ejemplo n.º 12
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);
        }
Ejemplo n.º 13
0
        public void T6_GetClients_RetrievesAllClientsWithStylist()
        {
            //Arrange
            Stylist testStylist = new Stylist("Amy Zee");

            testStylist.Save();

            //Act
            Client clientOne = new Client("Joe Lee", testStylist.GetId());
            Client clientTwo = new Client("Col Day", testStylist.GetId());

            clientOne.Save();
            clientTwo.Save();

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

            //Assert
            Assert.Equal(testClientList, resultClientList);
        }
Ejemplo n.º 14
0
        public void Test_GetClients_ReturnsTrueIfListsAreTheSame()
        {
            //Arrange
            Stylist newStylist = new Stylist("Harry Cutter", "a great stylist", 3);

            newStylist.Save();
            Client firstTestClient = new Client("Vin Diesel", newStylist.GetId());

            firstTestClient.Save();
            Client secondTestClient = new Client("Lady Gaga", newStylist.GetId());

            secondTestClient.Save();
            Client thirdTestClient = new Client("Mandy Moore", newStylist.GetId());

            thirdTestClient.Save();
            List <Client> expectedList = Client.GetAll();
            //Act
            List <Client> resultList = newStylist.GetClients();

            //Arrange
            Assert.Equal(resultList, expectedList);
        }
Ejemplo n.º 15
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);
        }
Ejemplo n.º 16
0
        public HomeModule()
        {
            Get["/"] = _ => {
                return(View["index.cshtml"]);
            }; //homepage

            Get["/salons"] = _ => {
                List <Salon> allSalons = Salon.GetAll();
                return(View["salons.cshtml", allSalons]);
            }; //list of all salons

            Get["/stylists"] = _ => {
                List <Stylist> allStylists = Stylist.GetAll();
                return(View["stylists.cshtml", allStylists]);
            }; //list of all stylists

            Get["/clients"] = _ => {
                List <Client> allClients = Client.GetAll();
                return(View["clients.cshtml", allClients]);
            }; //list of all clients

            Get["/salons/new"] = _ => {
                return(View["add_salon.cshtml"]);
            }; //navigates to form to add new salon

            Post["/salons/new"] = _ => {
                Salon newSalon = new Salon(Request.Form["salon-name"], Request.Form["salon-about"]);
                newSalon.Save();
                List <Salon> allSalons = Salon.GetAll();
                return(View["salons.cshtml", allSalons]);
            }; //posts from form adding new salon, returns list of all salons

            Get["/stylists/new"] = _ => {
                List <Salon> AllSalons = Salon.GetAll();
                return(View["add_stylist.cshtml", AllSalons]);
            }; //navigates to form to add new stylist

            Post["/stylists/new"] = _ => {
                Stylist newStylist = new Stylist(Request.Form["stylist-name"], Request.Form["stylist-bio"], Request.Form["salon-id"]);
                newStylist.Save();
                List <Stylist> allStylists = Stylist.GetAll();
                return(View["stylists.cshtml", allStylists]);
            }; //posts from form adding new stylist, returns list of all stylists

            Get["/clients/new"] = _ => {
                List <Stylist> AllStylists = Stylist.GetAll();
                return(View["add_client.cshtml", AllStylists]);
            }; //navigates to form to add new client

            Post["/clients/new"] = _ => {
                Client newClient = new Client(Request.Form["client-name"], Request.Form["stylist-id"]);
                newClient.Save();
                List <Client> allClients = Client.GetAll();
                return(View["clients.cshtml", allClients]);
            }; //posts from form adding new client, returns list of all clients

            Get["/salons/{id}"] = parameters => {
                Dictionary <string, object> model = new Dictionary <string, object>();
                Salon          SelectedSalon      = Salon.Find(parameters.id);
                List <Stylist> SalonStylists      = SelectedSalon.GetStylists();
                model.Add("salon", SelectedSalon);
                model.Add("stylists", SalonStylists);
                return(View["salon.cshtml", model]);
            }; //retrieves individual salon pages

            Get["/salon/{id}/edit"] = parameters => {
                Dictionary <string, object> model = new Dictionary <string, object> {
                };
                Salon  SelectedSalon = Salon.Find(parameters.id);
                string salonEdit     = Request.Query["salon-edit"];
                model.Add("form-type", salonEdit);
                model.Add("salon", SelectedSalon);
                return(View["edit.cshtml", model]);
            }; //edit individual salon

            Patch["/salon/{id}/edit"] = parameters => {
                Dictionary <string, object> model = new Dictionary <string, object>();
                Salon SelectedSalon = Salon.Find(parameters.id);
                SelectedSalon.Update(Request.Form["salon-name"], Request.Form["salon-about"]);
                List <Stylist> SalonStylists = SelectedSalon.GetStylists();
                model.Add("salon", SelectedSalon);
                model.Add("stylists", SalonStylists);
                return(View["salon.cshtml", model]);
            }; //returns edited salon page

            Get["salon/{id}/delete"] = parameters => {
                Dictionary <string, object> model = new Dictionary <string, object> {
                };
                Salon  SelectedSalon = Salon.Find(parameters.id);
                string salonDelete   = Request.Query["salon-delete"];
                model.Add("form-type", salonDelete);
                model.Add("salon", SelectedSalon);
                return(View["delete.cshtml", model]);
            }; //delete individual salon

            Delete["salon/{id}/delete"] = parameters => {
                Salon SelectedSalon = Salon.Find(parameters.id);
                SelectedSalon.Delete();
                List <Salon> allSalons = Salon.GetAll();
                return(View["salons.cshtml", allSalons]);
            }; //returns confirmation of deleted salon

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

            Get["/stylist/{id}/edit"] = parameters => {
                Dictionary <string, object> model = new Dictionary <string, object> {
                };
                Stylist SelectedStylist           = Stylist.Find(parameters.id);
                string  stylistEdit = Request.Query["stylist-edit"];
                model.Add("form-type", stylistEdit);
                model.Add("stylist", SelectedStylist);
                return(View["edit.cshtml", model]);
            }; //edit individual stylist

            Patch["/stylist/{id}/edit"] = parameters => {
                Dictionary <string, object> model = new Dictionary <string, object>();
                Stylist SelectedStylist           = Stylist.Find(parameters.id);
                SelectedStylist.Update(Request.Form["stylist-name"], Request.Form["stylist-bio"]);
                List <Client> StylistClients = SelectedStylist.GetClients();
                model.Add("stylist", SelectedStylist);
                model.Add("clients", StylistClients);
                return(View["stylist.cshtml", model]);
            }; //returns edited stylist page

            Get["stylist/{id}/delete"] = parameters => {
                Dictionary <string, object> model = new Dictionary <string, object> {
                };
                Stylist SelectedStylist           = Stylist.Find(parameters.id);
                string  stylistDelete             = Request.Query["stylist-delete"];
                model.Add("form-type", stylistDelete);
                model.Add("stylist", SelectedStylist);
                return(View["delete.cshtml", model]);
            }; //delete individual stylist

            Delete["stylist/{id}/delete"] = parameters => {
                Stylist SelectedStylist = Stylist.Find(parameters.id);
                SelectedStylist.Delete();
                List <Stylist> allStylists = Stylist.GetAll();
                return(View["stylists.cshtml", allStylists]);
            }; //returns confirmation of deleted stylist

            Get["/clients/{id}"] = parameters => {
                Client SelectedClient             = Client.Find(parameters.id);
                Dictionary <string, object> model = new Dictionary <string, object>();
                model.Add("client", SelectedClient);
                return(View["client.cshtml", model]);
            }; //retrieves individual client pages

            Get["/client/{id}/edit"] = parameters => {
                Dictionary <string, object> model = new Dictionary <string, object> {
                };
                Client SelectedClient             = Client.Find(parameters.id);
                string clientEdit = Request.Query["client-edit"];
                model.Add("form-type", clientEdit);
                model.Add("client", SelectedClient);
                return(View["edit.cshtml", model]);
            }; //edit individual client

            Patch["/client/{id}/edit"] = parameters => {
                Dictionary <string, object> model = new Dictionary <string, object>();
                Client SelectedClient             = Client.Find(parameters.id);
                SelectedClient.UpdateString(Request.Form["client-name"]);
                model.Add("client", SelectedClient);
                return(View["client.cshtml", model]);
            }; //returns edited client page

            Get["client/{id}/delete"] = parameters => {
                Dictionary <string, object> model = new Dictionary <string, object> {
                };
                Client SelectedClient             = Client.Find(parameters.id);
                string clientDelete = Request.Query["client-delete"];
                model.Add("form-type", clientDelete);
                model.Add("client", SelectedClient);
                return(View["delete.cshtml", model]);
            }; //delete individual client

            Delete["client/{id}/delete"] = parameters => {
                Client SelectedClient = Client.Find(parameters.id);
                SelectedClient.Delete();
                List <Client> allClients = Client.GetAll();
                return(View["clients.cshtml", allClients]);
            }; //returns confirmation of deleted client
        }
Ejemplo n.º 17
0
        public HomeModule()
        {
            Get["/"] = _ => {
                return(View["index.cshtml"]);
            };

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

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

            Get["/stylists/new"] = _ => {
                return(View["stylists_form.cshtml"]);
            };

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

            Get["/clients/new"] = _ => {
                List <Stylist> AllStylists = Stylist.GetAll();
                return(View["clients_form.cshtml", AllStylists]);
            };

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

            Post["/stylists/clear"] = _ => {
                Stylist.DeleteAll();
                return(View["cleared.cshtml"]);
            };

            Post["/clients/clear"] = _ => {
                Client.DeleteAll();
                return(View["cleared.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 => {
                Stylist SelectedStylist = Stylist.Find(parameters.id);
                return(View["stylist_edit.cshtml", SelectedStylist]);
            };

            Patch["/stylist/edit/{id}"] = parameters => {
                Dictionary <string, object> model = new Dictionary <string, object>();
                Stylist SelectedStylist           = Stylist.Find(parameters.id);
                SelectedStylist.Update(Request.Form["stylist-name"]);
                var StylistClients = SelectedStylist.GetClients();
                model.Add("stylist", SelectedStylist);
                model.Add("clients", StylistClients);
                return(View["stylist.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["success.cshtml"]);
            };

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

            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["client-name"]);
                return(View["client.cshtml", SelectedClient]);
            };

            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"]);
            };
        }
Ejemplo n.º 18
0
 public HomeModule()
 {
     Get["/"] = _ => {
         return(View["/index.cshtml"]);
     };
     Get["/add-new-stylist"] = _ => {
         return(View["/add-new-stylist.cshtml"]);
     };
     Get["/add-new-client"] = _ => {
         var allStylists = Stylist.GetAll();
         return(View["/add-new-client.cshtml", allStylists]);
     };
     Get["/success-stylist"] = _ => {
         return(View["/success-stylist.cshtml"]);
     };
     Get["/stylists"] = _ => {
         var allStylists = Stylist.GetAll();
         return(View["/stylists.cshtml", allStylists]);
     };
     Get["/clients"] = _ => {
         List <Client> allClients = Client.GetAll();
         return(View["/clients.cshtml", allClients]);
     };
     Post["/added-stylist"] = _ => {
         Stylist newStylist = new Stylist(Request.Form["stylist-name"], Request.Form["stylist-details"]);
         newStylist.Save();
         return(View["/success-stylist.cshtml"]);
     };
     Post["/added-client"] = _ => {
         Client newClient = new Client(Request.Form["client-name"], Request.Form["client-details"], Request.Form["client-stylist"]);
         newClient.Save();
         return(View["/success-client.cshtml"]);
     };
     Get["/stylist/update/{id}"] = parameters => {
         Stylist SelectedStylist = Stylist.Find(parameters.id);
         return(View["/stylist-update.cshtml", SelectedStylist]);
     };
     Patch["/stylist/update/{id}"] = parameters => {
         Stylist SelectedStylist = Stylist.Find(parameters.id);
         SelectedStylist.Update(Request.Form["stylist-details"]);
         return(View["/success-stylist-update.cshtml"]);
     };
     Get["/client/update/{id}"] = parameters => {
         Client SelectedClient = Client.Find(parameters.id);
         return(View["client-update.cshtml", SelectedClient]);
     };
     Patch["/client/update/{id}"] = parameters => {
         Client SelectedClient = Client.Find(parameters.id);
         SelectedClient.Update(Request.Form["client-details"]);
         return(View["/success-stylist-update.cshtml"]);
     };
     Get["/stylist/{id}"] = parameters => {
         Stylist selectedStylist           = Stylist.Find(parameters.id);
         Dictionary <string, object> model = new Dictionary <string, object>();
         List <Client> stylistClients      = selectedStylist.GetClients();
         model.Add("stylist", selectedStylist);
         model.Add("stylistClients", stylistClients);
         return(View["stylist.cshtml", model]);
     };
     Get["/client/{id}"] = parameters => {
         Client selectedClient             = Client.Find(parameters.id);
         Dictionary <string, object> model = new Dictionary <string, object>();
         int     clientStylistId           = selectedClient.GetClientStylistId();
         Stylist clientStylist             = Stylist.Find(clientStylistId);
         model.Add("client", selectedClient);
         model.Add("clientStylist", clientStylist);
         return(View["client.cshtml", model]);
     };
     Get["/stylist/delete/{id}"] = parameters => {
         Stylist SelectedStylist = Stylist.Find(parameters.id);
         SelectedStylist.Delete();
         return(View["/success-stylist-delete.cshtml"]);
     };
     Get["/client/delete/{id}"] = parameters => {
         Client SelectedClient = Client.Find(parameters.id);
         SelectedClient.Delete();
         return(View["/success-client-delete.cshtml"]);
     };
 }
Ejemplo n.º 19
0
 public HomeModule()
 {
     Get["/"] = _ => {
         Dictionary <string, object> model = new Dictionary <string, object> {
         };
         model.Add("listStylists", Stylist.GetAll());
         model.Add("listClients", Client.GetAll());
         model.Add("show-info", null);
         return(View["index.cshtml", model]);
     };
     Get["/stylists/new"] = _ => {
         Dictionary <string, string> model = new Dictionary <string, string> {
         };
         model.Add("form-type", "new-stylist");
         return(View["form.cshtml", model]);
     };
     Post["/stylists/new"] = _ => {
         Dictionary <string, object> model = new Dictionary <string, object> {
         };
         Stylist stylist = new Stylist(Request.Form["stylist-name"], Request.Form["stylist-rating"]);
         stylist.Save();
         model.Add("listClients", Client.GetAll());
         model.Add("listStylists", Stylist.GetAll());
         model.Add("newStylist", stylist);
         model.Add("show-info", Request.Form["show-info-new"]);
         return(View["index.cshtml", model]);
     };
     Get["/stylists/{id}/info"] = parameters => {
         Dictionary <string, object> model = new Dictionary <string, object> {
         };
         Stylist foundedStylist            = Stylist.Find(parameters.id);
         model.Add("listClients", Client.GetAll());
         model.Add("foundedStylist", foundedStylist);
         model.Add("show-info", "show-stylist");
         model.Add("listStylists", Stylist.GetAll());
         model.Add("stylistClients", foundedStylist.GetClients());
         return(View["index.cshtml", model]);
     };
     Get["/stylist/{id}/update"] = parameters => {
         Dictionary <string, object> model = new Dictionary <string, object> {
         };
         Stylist foundedStylist            = Stylist.Find(parameters.id);
         model.Add("foundedStylist", foundedStylist);
         model.Add("form-type", "update-stylist");
         model.Add("stylistClients", foundedStylist.GetClients());
         return(View["form.cshtml", model]);
     };
     Patch["/stylists/{id}/update"] = parameters => {
         Dictionary <string, object> model = new Dictionary <string, object> {
         };
         Stylist foundedStylist            = Stylist.Find(parameters.id);
         foundedStylist.Update(Request.Form["stylist-name"], Request.Form["stylist-rating"]);
         model.Add("updatedStylist", foundedStylist);
         model.Add("listClients", Client.GetAll());
         model.Add("listStylists", Stylist.GetAll());
         model.Add("stylistClients", foundedStylist.GetClients());
         model.Add("show-info", "update-stylist");
         return(View["index.cshtml", model]);
     };
     Get["/client/new"] = _ => {
         Dictionary <string, object> model = new Dictionary <string, object> {
         };
         model.Add("form-type", "new-client");
         model.Add("listStylists", Stylist.GetAll());
         return(View["form.cshtml", model]);
     };
     Post["/client/new"] = _ => {
         Dictionary <string, object> model = new Dictionary <string, object> {
         };
         Client client = new Client(Request.Form["client-name"], Request.Form["stylists"]);
         client.Save();
         model.Add("clientStylist", Stylist.Find(client.GetStylistId()));
         model.Add("newClient", client);
         model.Add("listClients", Client.GetAll());
         model.Add("show-info", "client-new");
         model.Add("listStylists", Stylist.GetAll());
         return(View["index.cshtml", model]);
     };
     Get["/clients/{id}/info"] = parameters => {
         Dictionary <string, object> model = new Dictionary <string, object> {
         };
         Client  foundedClient             = Client.Find(parameters.id);
         Stylist foundedStylist            = Stylist.Find(foundedClient.GetStylistId());
         model.Add("listStylists", Stylist.GetAll());
         model.Add("foundedClient", foundedClient);
         model.Add("foundedStylist", foundedStylist);
         model.Add("show-info", "show-client");
         model.Add("listClients", Client.GetAll());
         return(View["index.cshtml", model]);
     };
     Get["/clients/{id}/update"] = parameters => {
         Dictionary <string, object> model = new Dictionary <string, object> {
         };
         Client foundedClient = Client.Find(parameters.id);
         model.Add("foundedClient", foundedClient);
         model.Add("form-type", "update-client");
         model.Add("listStylists", Stylist.GetAll());
         return(View["form.cshtml", model]);
     };
     // Patch["/client/{id}/update"] = parameters => {
     //   Dictionary<string, object> model = new Dictionary<string, object>{};
     //   Client foundedClient = Client.Find(parameters.id);
     //   foundedClient.Update(Request.Form["client-name"], Request.Form["client-rating"]);
     //   model.Add("updatedClient", foundedClient);
     //   model.Add("listClients", Client.GetAll());
     //   model.Add("listStylists", Stylist.GetAll());
     //   model.Add("show-info", "update-client");
     //   return View["index.cshtml", model];
     // };
     Delete["/stylists/{id}/delete"] = parameters => {
         Dictionary <string, object> model = new Dictionary <string, object> {
         };
         Stylist foundedStylist            = Stylist.Find(parameters.id);
         foundedStylist.DeleteSingleStylist();
         model.Add("listStylists", Stylist.GetAll());
         model.Add("listClients", Client.GetAll());
         model.Add("show-info", "delete-stylist");
         model.Add("foundedStylist", foundedStylist);
         return(View["index.cshtml", model]);
     };
     Delete["/clients/{id}/delete"] = parameters => {
         Dictionary <string, object> model = new Dictionary <string, object> {
         };
         Client foundedClient = Client.Find(parameters.id);
         foundedClient.DeleteSingleClient();
         model.Add("listStylists", Stylist.GetAll());
         model.Add("listClients", Client.GetAll());
         model.Add("show-info", "delete-client");
         model.Add("foundedClient", foundedClient);
         return(View["index.cshtml", model]);
     };
     Delete["/stylists/delete_all"] = _ => {
         Dictionary <string, object> model = new Dictionary <string, object> {
         };
         Stylist.DeleteAll();
         model.Add("listStylists", Stylist.GetAll());
         model.Add("listClients", Client.GetAll());
         model.Add("show-info", "delete-all-stylists");
         return(View["index.cshtml", model]);
     };
     Delete["/clients/delete_all"] = _ => {
         Dictionary <string, object> model = new Dictionary <string, object> {
         };
         Client.DeleteAll();
         model.Add("listStylists", Stylist.GetAll());
         model.Add("listClients", Client.GetAll());
         model.Add("show-info", "delete-all-clients");
         return(View["index.cshtml", model]);
     };
 }
 public HomeModule()
 {
     Get["/"] = _ => {
         List <Stylist> allStylists = Stylist.GetAll();
         return(View["index.cshtml", allStylists]);
     };
     Get["/stylists/new"] = _ => {
         Dictionary <string, object> model = new Dictionary <string, object> {
         };
         string formType = Request.Query["form-type"];
         model.Add("form-type", formType);
         return(View["form.cshtml", model]);
     };
     Get["/stylists/{id}"] = parameters => {
         Dictionary <string, object> model = new Dictionary <string, object> {
         };
         Stylist       selectedStylist     = Stylist.Find(parameters.id);
         List <Client> selectedClients     = selectedStylist.GetClients();
         model.Add("clients", selectedClients);
         model.Add("stylist", selectedStylist);
         return(View["stylist.cshtml", model]);
     };
     Get["/stylists/{id}/clients/new"] = parameters => {
         Dictionary <string, object> model = new Dictionary <string, object> {
         };
         Stylist selectedStylist           = Stylist.Find(parameters.id);
         string  formType = Request.Query["form-type"];
         model.Add("form-type", formType);
         model.Add("stylist", selectedStylist);
         return(View["form.cshtml", model]);
     };
     Get["/stylists/delete"] = _ => {
         return(View["stylists_delete_confirmation.cshtml"]);
     };
     Get["/stylists/{stylistId}/clients/{clientId}/edit"] = parameters => {
         Dictionary <string, object> model = new Dictionary <string, object> {
         };
         string  formType        = Request.Query["form-type"];
         Stylist selectedStylist = Stylist.Find(parameters.stylistId);
         Client  selectedClient  = Client.Find(parameters.clientId);
         model.Add("form-type", formType);
         model.Add("client", selectedClient);
         model.Add("stylist", selectedStylist);
         return(View["form.cshtml", model]);
     };
     Get["/stylists/{stylistId}/edit"] = parameters => {
         Dictionary <string, object> model = new Dictionary <string, object> {
         };
         string  formType        = Request.Query["form-type"];
         Stylist selectedStylist = Stylist.Find(parameters.stylistId);
         model.Add("form-type", formType);
         model.Add("stylist", selectedStylist);
         return(View["form.cshtml", model]);
     };
     Get["/stylists/search"] = _ => {
         Dictionary <string, object> model = new Dictionary <string, object> {
         };
         string         searchQuery        = Request.Query["search-query"];
         List <Stylist> matches            = Stylist.SearchByName(searchQuery);
         model.Add("search-query", searchQuery);
         model.Add("matches", matches);
         return(View["results.cshtml", model]);
     };
     Post["/"] = _ => {
         Stylist newStylist = new Stylist(Request.Form["stylist-name"], Request.Form["stylist-telephone"]);
         newStylist.Save();
         List <Stylist> allStylists = Stylist.GetAll();
         return(View["index.cshtml", allStylists]);
     };
     Post["/stylists/{id}/clients/new"] = parameters => {
         Dictionary <string, object> model = new Dictionary <string, object> {
         };
         Client newClient = new Client(Request.Form["client-name"], Request.Form["client-telephone"], parameters.id);
         newClient.Save();
         Stylist       selectedStylist = Stylist.Find(parameters.id);
         List <Client> selectedClients = selectedStylist.GetClients();
         model.Add("clients", selectedClients);
         model.Add("stylist", selectedStylist);
         return(View["stylist.cshtml", model]);
     };
     Delete["/"] = _ => {
         Stylist.DeleteAll();
         List <Stylist> allStylists = Stylist.GetAll();
         return(View["index.cshtml", allStylists]);
     };
     Delete["/stylist/{id}/deleted"] = parameters => {
         Stylist selectedStylist = Stylist.Find(parameters.id);
         selectedStylist.Delete();
         List <Stylist> allStylists = Stylist.GetAll();
         return(View["index.cshtml", allStylists]);
     };
     Delete["/stylist/{id}/clients/deleted"] = parameters => {
         Dictionary <string, object> model = new Dictionary <string, object> {
         };
         Stylist selectedStylist           = Stylist.Find(parameters.id);
         selectedStylist.DeleteClients();
         List <Client> selectedClients = selectedStylist.GetClients();
         model.Add("clients", selectedClients);
         model.Add("stylist", selectedStylist);
         return(View["stylist.cshtml", model]);
     };
     Delete["/stylists/{stylistId}/clients/{clientId}/delete"] = parameters => {
         Dictionary <string, object> model = new Dictionary <string, object> {
         };
         Client  toDelete        = Client.Find(parameters.clientId);
         Stylist selectedStylist = Stylist.Find(parameters.stylistId);
         selectedStylist.DeleteClient(toDelete);
         List <Client> selectedClients = selectedStylist.GetClients();
         model.Add("clients", selectedClients);
         model.Add("stylist", selectedStylist);
         return(View["stylist.cshtml", model]);
     };
     Patch["/stylists/{stylistId}/clients/{clientId}/edit"] = parameters => {
         Dictionary <string, object> model = new Dictionary <string, object> {
         };
         Stylist selectedStylist           = Stylist.Find(parameters.stylistId);
         Client  selectedClient            = Client.Find(parameters.clientId);
         selectedClient.Update(Request.Form["client-name"], Request.Form["client-telephone"]);
         List <Client> selectedClients = selectedStylist.GetClients();
         model.Add("clients", selectedClients);
         model.Add("stylist", selectedStylist);
         return(View["stylist.cshtml", model]);
     };
     Patch["/stylists/{stylistId}/edit"] = parameters => {
         Dictionary <string, object> model = new Dictionary <string, object> {
         };
         Stylist selectedStylist           = Stylist.Find(parameters.stylistId);
         selectedStylist.Update(Request.Form["stylist-name"], Request.Form["stylist-telephone"]);
         List <Client> selectedClients = selectedStylist.GetClients();
         model.Add("clients", selectedClients);
         model.Add("stylist", selectedStylist);
         return(View["stylist.cshtml", model]);
     };
 }
Ejemplo n.º 21
0
        public HomeModule()
        {
            Get["/"] = _ =>
            {
                List <Client> AllClients = Client.GetAll();
                return(View["index.cshtml", AllClients]);
            };

            Get["/stylists"] = _ =>
            {
                List <Stylist> AllStylists = Stylist.GetAll();
                return(View["stylists.cshtml", AllStylists]);
            };
            Post["/stylists"] = _ =>
            {
                Stylist newStylist = new Stylist(Request.Form["stylist-name"]);
                newStylist.Save();
                List <Stylist> AllStylists = Stylist.GetAll();
                return(View["stylists.cshtml", AllStylists]);
            };

            Get["/stylists/new"] = _ =>
            {
                return(View["stylists-form.cshtml"]);
            };

            Get["/stylist/{id}"] = param =>
            {
                Stylist       Found        = Stylist.Find(param.id);
                List <Client> FoundClients = Found.GetClients();
                return(View["stylist.cshtml", FoundClients]);
            };

            Get["/stylists/{id}"] = param =>
            {
                Stylist       FoundStylist  = Stylist.Find(param.id);
                List <Client> ListOfClients = FoundStylist.GetClients();
                return(View["stylist.cshtml", ListOfClients]);
            };

            Post["/stylists/delete"] = _ =>
            {
                Stylist.DeleteAll();
                List <Stylist> AllStylists = Stylist.GetAll();
                return(View["stylists.cshtml", AllStylists]);
            };

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

            Post["/clients"] = _ =>
            {
                Client newClient = new Client(Request.Form["client-name"], Request.Form["client-stylist"]);
                newClient.Save();
                List <Client> AllClients = Client.GetAll();
                return(View["clients.cshtml", AllClients]);
            };

            Get["/clients/new"] = _ =>
            {
                List <Stylist> AllStylists = Stylist.GetAll();
                return(View["client-form.cshtml", AllStylists]);
            };

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

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

            Patch["clients/edit/{id}"] = param =>
            {
                Client SelectedClient = Client.Find(param.id);
                SelectedClient.Update(Request.Form["client-name"]);
                return(View["success.cshtml"]);
            };

            Get["client/delete/{id}"] = param =>
            {
                Client ThisClient = Client.Find(param.id);
                return(View["client-delete.cshtml", ThisClient]);
            };

            Delete["client/delete/{id}"] = param =>
            {
                Client SelectedClient = Client.Find(param.id);
                SelectedClient.Delete();
                return(View["success.cshtml"]);
            };

            Post["/clients/delete"] = _ =>
            {
                Client.DeleteAll();
                List <Client> AllClients = Client.GetAll();
                return(View["success.cshtml", AllClients]);
            };
        }
Ejemplo n.º 22
0
        public Homemodule()
        {
            Get["/"] = _ => {
                List <Stylist> AllStylists = Stylist.GetAll();
                return(View["index.cshtml", AllStylists]);
            };

            Get["/stylists"] = _ => {
                List <Stylist> AllStylists = Stylist.GetAll();
                return(View["stylists.cshtml", AllStylists]);
            };

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

            Get["/addAnotherStylist"] = _ => {
                List <Client> AllClients = Client.GetAll();
                return(View["addAnotherStylist.cshtml", AllClients]);
            };

            Get["/addNewClientToStylist"] = _ => {
                List <Stylist> AllStylists = Stylist.GetAll();
                return(View["addNewClientToStylist.cshtml", AllStylists]);
            };

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

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

            Get["/deleteAllStylists"] = _ => {
                Stylist.DeleteAll();
                return(View["deleteAllStylists.cshtml"]);
            };

            Get["/deleteAllClients"] = _ => {
                Client.DeleteAll();
                return(View["deleteAllClients.cshtml"]);
            };

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

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

            Patch["stylist/edit/{id}"] = parameters => {
                Stylist SelectedStylists = Stylist.Find(parameters.id);
                SelectedStylists.Update(Request.Form["stylist-name"]);
                return(View["index.cshtml", SelectedStylists]);
            };

            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["client-name"]);
                return(View["index.cshtml", SelectedClient]);
            };

            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["index.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["index.cshtml"]);
            };
        }