Exemplo n.º 1
0
        public void T1_DBEmptyAtFirst()
        {
            int result = Client.GetAll().Count;

            Assert.Equal(0, result);
        }
Exemplo n.º 2
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"]);
            };
        }
Exemplo n.º 3
0
 public HomeModule()
 {
     Get["/"] = _ => {
         return(View["index.cshtml"]);
     };
     Get["/stylists"] = _ => {
         List <Stylist> allStylists = Stylist.GetAll();
         return(View["stylists.cshtml", allStylists]);
     };
     Get["/stylists/new"] = _ => {
         return(View["stylist_add.cshtml"]);
     };
     Post["/stylists/new"] = _ => {
         Stylist newStylist = new Stylist(Request.Form["stylist-name"], Request.Form["stylist-specialty"]);
         newStylist.Save();
         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();
         // var clientFeedback = selectedClient.GetFeedback();
         model.Add("stylist", selectedStylist);
         model.Add("clients", stylistClients);
         // model.Add("feedback", clientFeedback);
         return(View["stylist.cshtml", model]);
     };
     Get["/clients"] = _ => {
         List <Client> allClients = Client.GetAll();
         return(View["clients.cshtml", allClients]);
     };
     Get["/clients/new"] = _ => {
         List <Stylist> allStylists = Stylist.GetAll();
         return(View["client_add.cshtml", allStylists]);
     };
     Post["/clients/new"] = _ => {
         Client newClient = new Client(Request.Form["client-name"], Request.Form["client-details"], Request.Form["stylist-id"]);
         newClient.Save();
         return(View["success.cshtml"]);
     };
     Get["/clients/{id}"] = parameters => {
         Dictionary <string, object> model = new Dictionary <string, object>();
         var selectedClient = Client.Find(parameters.id);
         // var clientStylist = selectedClient.GetStylist();
         model.Add("client", selectedClient);
         // model.Add("stylist", clientStylist);
         return(View["client.cshtml", model]);
     };
     Get["clients/{id}/edit"] = parameters => {
         Dictionary <string, object> model = new Dictionary <string, object>();
         Client selectedClient             = Client.Find(parameters.id);
         model.Add("selectedClient", selectedClient);
         return(View["client_edit.cshtml", model]);
     };
     Patch["/clients/{id}/edit"] = parameters => {
         Client selectedClient = Client.Find(parameters.id);
         string newClientName  = Request.Form["client-name"];
         string newDetails     = Request.Form["client-details"];
         if (newClientName == "" && newDetails != "")
         {
             selectedClient.UpdateDetails(newDetails);
         }
         else if (newClientName != "" && newDetails == "")
         {
             selectedClient.UpdateClientName(newClientName);
         }
         else
         {
             selectedClient.UpdateDetails(newDetails);
             selectedClient.UpdateClientName(newClientName);
         }
         return(View["success.cshtml"]);
     };
     Get["stylists/{id}/delete"] = parameters => {
         Stylist selectedStylist = Stylist.Find(parameters.id);
         return(View["stylist_delete.cshtml", selectedStylist]);
     };
     Delete["stylists/{id}/delete"] = parameters => {
         Stylist selectedStylist = Stylist.Find(parameters.id);
         selectedStylist.Delete();
         return(View["success.cshtml"]);
     };
     Get["clients/{id}/delete"] = parameters => {
         Client selectedClient = Client.Find(parameters.id);
         return(View["client_delete.cshtml", selectedClient]);
     };
     Delete["clients/{id}/delete"] = parameters => {
         Client selectedClient = Client.Find(parameters.id);
         selectedClient.Delete();
         return(View["success.cshtml"]);
     };
 }