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.º 2
0
 public void Dispose()
 {
     Client.DeleteAll();
     Stylist.DeleteAll();
 }
Ejemplo n.º 3
0
 public void Dispose()
 {
     Stylist.DeleteAll();
 }
Ejemplo n.º 4
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.º 5
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"]);
            };
        }
Ejemplo n.º 6
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"] = _ => {
                List <Stylist> AllStylists = Stylist.GetAll();
                return(View["stylists.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"]);
            };

            Post["/stylists/delete"] = _ => {
                Stylist.DeleteAll();
                return(View["delete_all.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"]);
                newClient.Save();
                return(View["success.cshtml"]);
            };

            // Post["/clients/delete"] = _ => {
            //   Client.DeleteAll();
            //   return View["delete_all.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 => {
                Stylist SelectedStylist = Stylist.Find(parameters.id);
                SelectedStylist.Update(Request.Form["stylist-name"]);
                return(View["success.cshtml"]);
            };

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

            Delete["stylist/delete/{id}"] = parameters => {
                Stylist SelectedStylist = Stylist.Find(parameters.id);
                SelectedStylist.Delete();
                return(View["delete_all.cshtml"]);
            };
        }
Ejemplo n.º 7
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]);
     };
 }
Ejemplo n.º 8
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"]);
            };
        }
Ejemplo n.º 9
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"]);
     };
 }