Пример #1
0
        public void Test_Update_ClientInDatabase()
        {
            //Arrange
            string name       = "Morty Smith";
            string phone      = "555-555-5555";
            string email      = "*****@*****.**";
            int    stylistId  = 3;
            Client testClient = new Client(name, phone, email, stylistId);

            testClient.Save();
            string newName      = "EvilMorty";
            string newPhone     = "555-545-5555";
            string newEmail     = "*****@*****.**";
            int    newStylistId = 2;

            //Act
            testClient.Update(newName, newPhone, newEmail, newStylistId);
            int result = testClient.GetStylistId();

            //Assert
            Assert.Equal(newStylistId, result);
        }
Пример #2
0
 public HomeModule()
 {
     Get["/"] = _ => {
         List <Stylist> allStylists = Stylist.GetAll();
         return(View["index.cshtml", allStylists]);
     };
     Get["/stylist/new"] = _ => {
         return(View["stylist_form.cshtml"]);
     };
     Post["/stylist/add"] = _ => {
         Stylist newStylist = new Stylist(Request.Form["stylist-name"]);
         newStylist.Save();
         List <Stylist> allStylists = Stylist.GetAll();
         return(View["index.cshtml", allStylists]);
     };
     Get["/client/{id}"] = parameter => {
         Stylist stylistClients = Stylist.Find(parameter.id);
         return(View["stylist.cshtml", stylistClients]);
     };
     Post["/client/add/{id}"] = parameter => {
         Client newClient = new Client(Request.Form["client-name"], parameter.id);
         newClient.Save();
         Stylist stylistClients = Stylist.Find(parameter.id);
         return(View["stylist.cshtml", stylistClients]);
     };
     Get["/stylist/edit/{id}"] = parameter => {
         Stylist selectedStylist = Stylist.Find(parameter.id);
         return(View["stylist_edit.cshtml", selectedStylist]);
     };
     Patch["/stylist/edit/{id}"] = parameter => {
         Stylist selectedStylist = Stylist.Find(parameter.id);
         selectedStylist.Update(Request.Form["new-stylist-name"]);
         List <Stylist> allStylists = Stylist.GetAll();
         return(View["index.cshtml", allStylists]);
     };
     Get["/stylist/delete/{id}"] = parameter => {
         Stylist selectedStylist = Stylist.Find(parameter.id);
         return(View["stylist_delete.cshtml", selectedStylist]);
     };
     Delete["/stylist/delete/{id}"] = parameter => {
         Stylist selectedStylist = Stylist.Find(parameter.id);
         selectedStylist.Delete();
         List <Stylist> allStylists = Stylist.GetAll();
         return(View["index.cshtml", allStylists]);
     };
     Get["/clients"] = _ => {
         List <Client> allClients = Client.GetAll();
         return(View["clients.cshtml", allClients]);
     };
     Get["/clients/{id}"] = parameter => {
         Client selectedClient = Client.Find(parameter.id);
         return(View["client.cshtml", selectedClient]);
     };
     Get["/client/edit/{id}"] = parameter => {
         Client selectedClient = Client.Find(parameter.id);
         return(View["client_edit.cshtml", selectedClient]);
     };
     Patch["/client/edit/{id}"] = parameter => {
         Client  selectedClient = Client.Find(parameter.id);
         Stylist currentStylist = Stylist.Find(selectedClient.GetStylistId());
         selectedClient.Update(Request.Form["new-client-name"], currentStylist.GetId());
         List <Client> allClients = Client.GetAll();
         return(View["clients.cshtml", allClients]);
     };
 }
Пример #3
0
        public HomeModule()
        {
            Get["/"] = _ => {
                List <Stylist> allStylists = Stylist.GetAll();
                return(View["index.cshtml", allStylists]);
            };

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

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

            Post["/stylists/new"] = _ => {
                string stylistName        = Request.Form["stylist-name"];
                string stylistPhone       = Request.Form["stylist-phone"];
                string stylistDescription = Request.Form["stylist-description"];

                Stylist newStylist = new Stylist(stylistName, stylistPhone, stylistDescription);
                newStylist.Save();
                return(View["stylist_added.cshtml", newStylist]);
            };

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

            Post["/clients/new"] = _ => {
                Dictionary <string, object> model = new Dictionary <string, object> ();
                string clientName        = Request.Form["client-name"];
                string clientDescription = Request.Form["client-description"];
                int    clientStylistId   = int.Parse(Request.Form["client-stylist-id"]);

                Client newClient = new Client(clientName, clientDescription, clientStylistId);
                newClient.Save();

                Stylist assignedStylist = Stylist.Find(clientStylistId);
                model.Add("client", newClient);
                model.Add("stylist", assignedStylist);
                return(View["client_added.cshtml", model]);
            };

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

            Get["/client/{id}"] = parameters => {
                Dictionary <string, object> model = new Dictionary <string, object> ();
                Client  selectedClient            = Client.Find(parameters.id);
                Stylist selectedStylist           = Stylist.Find(selectedClient.GetStylistId());
                model.Add("client", selectedClient);
                model.Add("stylist", selectedStylist);
                return(View["client.cshtml", model]);
            };

            Get["/stylist/{id}/new_client"] = parameters => {
                Stylist selectedStylist = Stylist.Find(parameters.id);
                return(View["specific_stylist_client_form.cshtml", selectedStylist]);
            };

            Post["/stylist/{id}/new_client"] = parameters => {
                Dictionary <string, object> model = new Dictionary <string, object> ();
                Stylist selectedStylist           = Stylist.Find(parameters.id);

                string clientName        = Request.Form["client-name"];
                string clientDescription = Request.Form["client-description"];
                int    clientStylistId   = selectedStylist.GetId();

                Client newClient = new Client(clientName, clientDescription, clientStylistId);
                newClient.Save();
                model.Add("client", newClient);
                model.Add("stylist", selectedStylist);
                return(View["client_added.cshtml", model]);
            };

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

            Patch["/stylist/edit/{id}"] = parameters => {
                Stylist selectedStylist = Stylist.Find(parameters.id);

                string stylistName        = Request.Form["stylist-name"];
                string stylistPhone       = Request.Form["stylist-phone"];
                string stylistDescription = Request.Form["stylist-description"];

                selectedStylist.Update(stylistName, stylistPhone, stylistDescription);
                Stylist updatedStylist = Stylist.Find(parameters.id);
                return(View["stylist_edited.cshtml", updatedStylist]);
            };

            Get["/client/edit/{id}"] = parameters => {
                Dictionary <string, object> model = new Dictionary <string, object> ();
                Client  selectedClient            = Client.Find(parameters.id);
                Stylist selectedStylist           = Stylist.Find(selectedClient.GetStylistId());
                model.Add("client", selectedClient);
                model.Add("all stylists", Stylist.GetAll());
                return(View["client_edit.cshtml", model]);
            };

            Patch["/client/edit/{id}"] = parameters => {
                Dictionary <string, object> model = new Dictionary <string, object> ();
                Client selectedClient             = Client.Find(parameters.id);

                string clientName        = Request.Form["client-name"];
                string clientDescription = Request.Form["client-description"];
                int    clientStylistId   = int.Parse(Request.Form["client-stylist-id"]);

                selectedClient.Update(clientName, clientDescription, clientStylistId);
                Client  updatedClient   = Client.Find(parameters.id);
                Stylist selectedStylist = Stylist.Find(updatedClient.GetStylistId());

                model.Add("client", updatedClient);
                model.Add("stylist", selectedStylist);
                return(View["client_edited.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["entry_deleted.cshtml"]);
            };

            Get["/client/delete/{id}"] = parameters => {
                Dictionary <string, object> model = new Dictionary <string, object> ();
                Client  selectedClient            = Client.Find(parameters.id);
                Stylist selectedStylist           = Stylist.Find(selectedClient.GetStylistId());

                model.Add("client", selectedClient);
                model.Add("stylist", selectedStylist);
                return(View["client_delete.cshtml", model]);
            };

            Delete["/client/delete/{id}"] = parameters => {
                Client selectedClient = Client.Find(parameters.id);
                selectedClient.Delete();
                return(View["entry_deleted.cshtml"]);
            };
        }
Пример #4
0
        public HomeModule()
        {
            Get["/"] = _ => {
                List <Stylist> AllStylists = Stylist.GetAll();
                return(View["index.cshtml", AllStylists]);
            };

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

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

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

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

//
            Post["/clients/new"] = _ => {
                Dictionary <string, object> model = new Dictionary <string, object> ();
                string clientName      = Request.Form["client-name"];
                int    clientStylistId = int.Parse(Request.Form["stylistId"]);

                Client newClient = new Client(clientName, clientStylistId);
                newClient.Save();

                Stylist assignedStylist = Stylist.Find(clientStylistId);
                model.Add("client", newClient);
                model.Add("stylist", assignedStylist);
                return(View["success.cshtml", model]);
            };

            //Routes for our individual view pages
            Get["/stylist/{id}"] = parameters => {
                Stylist selectedStylist = Stylist.Find(parameters.id);
                return(View["stylist.cshtml", selectedStylist]);
            };

            Get["/client/{id}"] = parameters => {
                Dictionary <string, object> model = new Dictionary <string, object>();
                Client selectedClient             = Client.Find(parameters.id);
                var    SelectedStylist            = Stylist.Find(selectedClient.GetStylistId());
                model.Add("client", selectedClient);
                model.Add("stylist", SelectedStylist);
                return(View["client.cshtml", model]);
            };

            Get["stylist/update/{id}"] = parameters => {
                Stylist model = Stylist.Find(parameters.id);
                return(View["stylist_update.cshtml", model]);
            };

            Patch["stylist/update/{id}"] = parameters => {
                Stylist selectedStylist = Stylist.Find(parameters.id);

                string stylistName = Request.Form["stylist-name"];
                selectedStylist.Update(stylistName);
                Stylist updatedStylist = Stylist.Find(parameters.id);
                return(View["success.cshtml", updatedStylist]);
            };

            Get["/stylist/{id}/new_client"] = parameters =>
            {
                Stylist selectedStylist = Stylist.Find(parameters.id);
                return(View["client_to_stylist_form.cshtml.cshtml", selectedStylist]);
            };

            Post["/stylist/{id}/new_client"] = parameters => {
                Dictionary <string, object> model = new Dictionary <string, object> ();
                Stylist selectedStylist           = Stylist.Find(parameters.id);

                string clientName      = Request.Form["client-name"];
                int    clientStylistId = selectedStylist.GetId();

                Client newClient = new Client(clientName, clientStylistId);
                newClient.Save();
                model.Add("client", newClient);
                model.Add("stylist", selectedStylist);
                return(View["success.cshtml", model]);
            };

            Get["/client/update/{id}"] = parameters => {
                Dictionary <string, object> model = new Dictionary <string, object> ();
                Client  selectedClient            = Client.Find(parameters.id);
                Stylist selectedStylist           = Stylist.Find(selectedClient.GetStylistId());
                model.Add("client", selectedClient);
                model.Add("all stylists", Stylist.GetAll());
                return(View["client_update.cshtml", model]);
            };

            Patch["/client/update/{id}"] = parameters => {
                Dictionary <string, object> model = new Dictionary <string, object> ();
                Client selectedClient             = Client.Find(parameters.id);

                string clientName      = Request.Form["client-name"];
                int    clientStylistId = int.Parse(Request.Form["client-stylist-id"]);

                selectedClient.Update(clientName, clientStylistId);
                Client  updatedClient   = Client.Find(parameters.id);
                Stylist SelectedStylist = Stylist.Find(updatedClient.GetStylistId());

                model.Add("client", updatedClient);
                model.Add("stylist", SelectedStylist);
                return(View["success.cshtml", model]);
            };

            Get["/stylist/delete/{id}"] = parameters => {
                Stylist selectedStylist = Stylist.Find(parameters.id);
                return(View["cleared.cshtml", selectedStylist]);
            };

            Delete["/stylist/delete/{id}"] = parameters => {
                Stylist selectedStylist = Stylist.Find(parameters.id);
                selectedStylist.Delete();
                return(View["success.cshtml"]);
            };

            Get["/client/delete/{id}"] = parameters => {
                Dictionary <string, object> model = new Dictionary <string, object> ();
                Client  selectedClient            = Client.Find(parameters.id);
                Stylist SelectedStylist           = Stylist.Find(selectedClient.GetStylistId());

                model.Add("client", selectedClient);
                model.Add("stylist", SelectedStylist);
                return(View["cleared.cshtml", model]);
            };

            Delete["/client/delete/{id}"] = parameters => {
                Client selectedClient = Client.Find(parameters.id);
                selectedClient.Delete();
                return(View["success.cshtml"]);
            };
        }
Пример #5
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]);
     };
 }
Пример #6
0
 public HomeModule()
 {
     Get["/"] = _ => {
         return(View["index.cshtml"]);
     };
     //CREATE
     Get["/client/new"] = _ => {
         List <Stylist> AllStylists = Stylist.GetAll();
         return(View["add_client.cshtml", AllStylists]);
     };
     Get["/stylist/new"] = _ => {
         return(View["add_stylist.cshtml"]);
     };
     Post["/clients"] = _ => {
         Dictionary <string, object> model = new Dictionary <string, object>();
         Client newClient       = new Client(Request.Form["client-name"], Request.Form["client-phone"], Request.Form["client-email"], Request.Form["stylist"]);
         var    selectedStylist = Stylist.Find(newClient.GetStylistId());
         newClient.Save();
         model.Add("stylist", selectedStylist);
         model.Add("client", newClient);
         return(View["success.cshtml", model]);
     };
     Post["/stylists"] = _ => {
         Dictionary <string, object> model = new Dictionary <string, object>();
         Stylist newStylist      = new Stylist(Request.Form["stylist-name"], Request.Form["stylist-phone"], Request.Form["stylist-email"]);
         var     selectedStylist = Stylist.Find(newStylist.GetId());
         newStylist.Save();
         model.Add("stylist", newStylist);
         return(View["success.cshtml", newStylist]);
     };
     //READ
     Get["/clients"] = _ => {
         List <Client> AllClients = Client.GetAll();
         return(View["clients.cshtml", AllClients]);
     };
     Get["/stylists"] = _ => {
         List <Stylist> AllStylist = Stylist.GetAll();
         return(View["stylists.cshtml", AllStylist]);
     };
     Get["/clients/{id}"] = parameters => {
         Dictionary <string, object> model = new Dictionary <string, object>();
         var selectedClient  = Client.Find(parameters.id);
         var selectedStylist = Stylist.Find(selectedClient.GetStylistId());
         model.Add("stylist", selectedStylist);
         model.Add("client", selectedClient);
         return(View["client.cshtml", model]);
     };
     Get["/stylists/{id}"] = parameters => {
         Dictionary <string, object> model = new Dictionary <string, object>();
         var selectedStylist = Stylist.Find(parameters.id);
         var ClientsStylist  = selectedStylist.GetClients();
         model.Add("stylist", selectedStylist);
         model.Add("clients", ClientsStylist);
         return(View["stylist.cshtml", model]);
     };
     //UPDATE
     Get["/client/edit/{id}"] = parameters => {
         Dictionary <string, object> model = new Dictionary <string, object> {
         };
         Client         SelectedClient     = Client.Find(parameters.id);
         List <Stylist> AllStylists        = Stylist.GetAll();
         model.Add("client", SelectedClient);
         model.Add("stylists", Stylist.GetAll());
         return(View["edit_client.cshtml", model]);
     };
     Get["/stylist/edit/{id}"] = parameters => {
         Stylist SelectedStylist = Stylist.Find(parameters.id);
         return(View["edit_stylist.cshtml", SelectedStylist]);
     };
     Patch["/client/edit/{id}"] = parameters => {
         Client SelectedClient  = Client.Find(parameters.id);
         var    selectedStylist = Stylist.Find(SelectedClient.GetStylistId());
         SelectedClient.Update(Request.Form["client-name"], Request.Form["client-phone"], Request.Form["client-email"], Request.Form["stylist-id"]);
         return(View["success.cshtml"]);
     };
     Patch["/stylist/edit/{id}"] = parameters => {
         Stylist SelectedStylist = Stylist.Find(parameters.id);
         SelectedStylist.Update(Request.Form["stylist-name"], Request.Form["stylist-phone"], Request.Form["stylist-email"]);
         return(View["success.cshtml"]);
     };
     //DESTROY
     Get["client/delete/{id}"] = parameters => {
         Client SelectedClient = Client.Find(parameters.id);
         return(View["delete_client.cshtml", SelectedClient]);
     };
     Get["stylist/delete/{id}"] = parameters => {
         Stylist SelectedStylist = Stylist.Find(parameters.id);
         return(View["delete_stylist.cshtml", SelectedStylist]);
     };
     Delete["client/delete/{id}"] = parameters => {
         Client SelectedClient = Client.Find(parameters.id);
         SelectedClient.Delete();
         return(View["success.cshtml"]);
     };
     Delete["stylist/delete/{id}"] = parameters => {
         Stylist SelectedStylist = Stylist.Find(parameters.id);
         SelectedStylist.Delete();
         return(View["success.cshtml"]);
     };
     Post["/clients/cleared"] = _ => {
         Client.DeleteAll();
         return(View["cleared.cshtml"]);
     };
     Post["/stylists/cleared"] = _ => {
         Client.DeleteAll();
         Stylist.DeleteAll();
         return(View["cleared.cshtml"]);
     };
 }
Пример #7
0
 public HomeModule()
 {
     Get["/"] = _ => {
         List <Stylist> allStylists = Stylist.GetAll();
         return(View["index.cshtml", allStylists]);
     };
     Get["/stylist/add"] = _ => {
         return(View["new-stylist-form.cshtml"]);
     };
     Post["/stylist/add"] = _ => {
         Stylist newStylist = new Stylist(Request.Form["stylistName"]);
         newStylist.Save();
         List <Stylist> allStylists = Stylist.GetAll();
         return(View["index.cshtml", allStylists]);
     };
     Get["/stylist/{id}"] = parameters => {
         Stylist currentStylist = Stylist.Find(parameters.id);
         return(View["stylist.cshtml", currentStylist]);
     };
     Get["/client/add"] = _ => {
         List <Stylist> allStylists = Stylist.GetAll();
         return(View["new-client-form.cshtml", allStylists]);
     };
     Post["/client/add"] = _ => {
         Client newClient = new Client(Request.Form["clientName"], Request.Form["clientStylistId"]);
         newClient.Save();
         List <Stylist> allStylists = Stylist.GetAll();
         return(View["index.cshtml", allStylists]);
     };
     Get["/client/{id}"] = parameters => {
         Client currentClient = Client.Find(parameters.id);
         return(View["client.cshtml", currentClient]);
     };
     Get["/stylist/edit/{id}"] = parameters => {
         Stylist currentStylist = Stylist.Find(parameters.id);
         return(View["edit-stylist-form.cshtml", currentStylist]);
     };
     Patch["/stylist/edit/{id}"] = parameters => {
         Stylist currentStylist = Stylist.Find(parameters.id);
         currentStylist.Edit(Request.Form["stylistName"]);
         return(View["stylist.cshtml", currentStylist]);
     };
     Get["/client/edit/{id}"] = parameters => {
         Client currentClient = Client.Find(parameters.id);
         return(View["edit-client-form.cshtml", currentClient]);
     };
     Patch["/client/edit/{id}"] = parameters => {
         Client currentClient = Client.Find(parameters.id);
         currentClient.Edit(Request.Form["clientName"], currentClient.GetStylistId());
         return(View["client.cshtml", currentClient]);
     };
     Delete["/stylist/delete/{id}"] = parameters => {
         Stylist currentStylist = Stylist.Find(parameters.id);
         currentStylist.Delete();
         List <Stylist> allStylists = Stylist.GetAll();
         return(View["index.cshtml", allStylists]);
     };
     Delete["/client/delete/{id}"] = parameters => {
         Client  currentClient  = Client.Find(parameters.id);
         Stylist currentStylist = Stylist.Find(currentClient.GetStylistId());
         currentClient.Delete();
         return(View["stylist.cshtml", currentStylist]);
     };
 }