Пример #1
0
        public void Test_RetrievedAllClientsWithinStylist_True()
        {
            Stylist testStylist = new Stylist("Jordan Loop");

            testStylist.Save();

            Client firstClient  = new Client("Donald Duck", testStylist.GetId());
            Client secondClient = new Client("Happy Tree", testStylist.GetId());

            firstClient.Save();
            secondClient.Save();

            List <Client> testClient = new List <Client> {
                firstClient, secondClient
            };
            List <Client> resultClientList = testStylist.GetClient();
        }
Пример #2
0
        public void Test_GetClients_RetrievesAllClientsWithinStylist()
        {
            Stylist testStylist = new Stylist("Sam");

            testStylist.Save();

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

            firstClient.Save();
            secondClient.Save();

            List <Client> testClientList = new List <Client> {
                firstClient, secondClient
            };
            List <Client> resultClientList = testStylist.GetClient();
        }
Пример #3
0
        public HomeModule()
        {
            //root -> index.cshtml
            Get["/"] = _ => {
                return(View["index.cshtml"]);
            };

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

            //stylist/add -> add-stylist.cshtml
            Get["/stylist/add"] = _ => {
                return(View["add-stylist.cshtml"]);
            };

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

            //stylist/add -> all-stylist
            Post["/stylist/delete-all"] = _ => {
                Stylist.DeleteAll();
                return(View["confirmed.cshtml"]);
            };

            Get["/stylist/view/{id}"] = param => {
                Dictionary <string, object> model = new Dictionary <string, object>();
                Stylist       selectedStylist     = Stylist.Find(param.id);
                List <Client> stylistClients      = selectedStylist.GetClient();

                model.Add("Stylist", selectedStylist);
                model.Add("Clients", stylistClients);
                return(View["view-stylist.cshtml", model]);
            };


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

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

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

            Get["/client/edit/{id}"] = param => {
                Client selectedClient = Client.Find(param.id);
                return(View["edit-client.cshtml", selectedClient]);
            };
            Patch["client/edit/{id}"] = param => {
                Client SelectedClient = Client.Find(param.id);
                SelectedClient.Update(Request.Form["edit-client"]);
                return(View["confirmed.cshtml"]);
            };
        }
Пример #4
0
        public HomeModule()
        {
            Get["/"] = _ => {
                return(View["root.cshtml"]);
            };
            Get["/stylists/add"] = _ => {
                return(View["add-stylists.cshtml"]);
            };
            Get["/stylists/all"] = _ => {
                List <Stylist> allStylists = Stylist.GetAll();
                return(View["all-stylists.cshtml", allStylists]);
            };
            Post["stylists/all"] = _ => {
                Stylist newStylist = new Stylist(Request.Form["stylist-name"]);
                newStylist.Save();
                List <Stylist> allStylists = Stylist.GetAll();
                return(View["all-stylists.cshtml", allStylists]);
            };
            Get["/stylists/{id}"] = parameter => {
                Dictionary <string, object> model = new Dictionary <string, object>();
                Stylist       SelectedStylist     = Stylist.Find(parameter.id);
                List <Client> StylistClient       = SelectedStylist.GetClient();
                model.Add("Stylist", SelectedStylist);
                model.Add("Client", StylistClient);
                return(View["clients.cshtml", model]);
            };
            Post["/stylists/delete"] = _ => {
                Stylist.DeleteAll();
                return(View["deleteAll-confirm.cshtml"]);
            };
            Get["/clients/add"] = _ => {
                List <Stylist> allStylists = Stylist.GetAll();
                return(View["add-client.cshtml", allStylists]);
            };
            Post["/clients/all"] = _ => {
                Client newClient = new Client(Request.Form["client-name"], Request.Form["client-id"]);
                newClient.Save();
                return(View["root.cshtml"]);
            };
            Get["client/edit/{id}"] = parameter => {
                Client SelectedClient = Client.Find(parameter.id);
                return(View["edit-client.cshtml", SelectedClient]);
            };
            Patch["client/edit/{id}"] = parameter => {
                Client SelectedClient = Client.Find(parameter.id);
                SelectedClient.Update(Request.Form["edit-client"]);
                List <Client> allClients = Client.GetAll();
                return(View["root.cshtml", allClients]);
            };
            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["root.cshtml"]);
            };


            Get["stylist/edit/{id}"] = parameter => {
                Stylist SelectedStylist = Stylist.Find(parameter.id);
                return(View["edit-stylist.cshtml", SelectedStylist]);
            };
            Patch["stylist/edit/{id}"] = parameter => {
                Stylist SelectedStylist = Stylist.Find(parameter.id);
                SelectedStylist.Update(Request.Form["edit-stylist"]);
                List <Stylist> allStylists = Stylist.GetAll();
                return(View["root.cshtml", allStylists]);
            };
            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["root.cshtml"]);
            };
        }