Example #1
0
        public void T8_GetClients_RetrievesAllClientsOfStylist()
        {
            Stylist testStylist = new Stylist("Jake", "Shears", "L.5 Master");

            testStylist.Save();

            Client testClient1 = new Client("Shaggy", "Dew", testStylist.GetId());

            testClient1.Save();
            Client testClient2 = new Client("Lange", "Ponyta", testStylist.GetId());

            testClient2.Save();

            List <Client> testClients = new List <Client> {
                testClient1, testClient2
            };
            List <Client> result = testStylist.GetClients();

            Assert.Equal(testClients, result);
        }
Example #2
0
        [Fact] //Spec 4
        public void Test_GetClients_RetrievesAllClientsForStylist()
        {
            Stylist testStylist = new Stylist("Emmylou Earnest", "Men's cuts and short hair styles.");

            testStylist.Save();

            Client firstClient = new Client("Darla Darling", "On her last visit (1/2/2013), we trimmed her hair and touched up her roots with dark drown.", testStylist.GetId());

            firstClient.Save();
            Client secondClient = new Client("Beau Blue", "On his last visit, we shaved his sides and trimmed the top.", testStylist.GetId());

            secondClient.Save();

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

            Assert.Equal(testClientList, resultClientList);
        }
Example #3
0
        public void Test_GetClients_RetrievesAll_Clients_WithStylist()
        {
            Stylist testStylist = new Stylist("Abraham Lincoln");

            testStylist.Save();

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

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

            secondClient.Save();


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

            Assert.Equal(testClientList, resultClientList);
        }
Example #4
0
        public void Test_GetClients_RetrievesAllClientssWithCategory()
        {
            Stylist testStylist = new Stylist("Bob", 1);

            testStylist.Save();

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

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

            secondClient.Save();


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

            Assert.Equal(testClientList, resultClientList);
        }
Example #5
0
        public void Test_GetClients_RetrievesAllClientsWithStylist()
        {
            Stylist testStylist = new Stylist("nancy");

            testStylist.Save();

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

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

            secondClient.Save();


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

            Assert.Equal(testClientList, resultClientList);
        }
Example #6
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]);
            };
        }
Example #7
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"]);
            };
        }