Пример #1
0
        public void TestStylist_Delete_SingleStylist()
        {
            Stylist newStylist1 = new Stylist("Jessica", 5);

            newStylist1.Save();
            Stylist newStylist2 = new Stylist("Joan", 3);

            newStylist2.Save();

            newStylist1.DeleteSingleStylist();

            List <Stylist> controlList = new List <Stylist> {
                newStylist2
            };
            List <Stylist> testList = Stylist.GetAll();

            Assert.Equal(controlList, testList);
        }
Пример #2
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]);
     };
 }