public void Test_Delete_DeletesCategoryFromDatabase()
        {
            //Arrange
              string name1 = "Home stuff";
              Category testCategory1 = new Category(name1);
              testCategory1.Save();

              string name2 = "Work stuff";
              Category testCategory2 = new Category(name2);
              testCategory2.Save();
              DateTime fakeTime = new DateTime(2016, 1, 1);

              Task testTask1 = new Task("Mow the lawn", testCategory1.GetId(),fakeTime);
              testTask1.Save();
              DateTime fakeTime1 = new DateTime(2016, 1, 1);

              Task testTask2 = new Task("Send emails", testCategory2.GetId(),fakeTime1);
              testTask2.Save();

              //Act
              testCategory1.Delete();
              List<Category> resultCategories = Category.GetAll();
              List<Category> testCategoryList = new List<Category> {testCategory2};

              List<Task> resultTasks = Task.GetAll();
              List<Task> testTaskList = new List<Task> {testTask2};

              //Assert
              Assert.Equal(testCategoryList, resultCategories);
              Assert.Equal(testTaskList, resultTasks);
        }
        public void Test_Delete_DeletesCategoryFromDatabase()
        {
            string   name1         = "Home stuff";
            Category testCategory1 = new Category(name1);

            testCategory1.Save();

            string   name2         = "Work stuff";
            Category testCategory2 = new Category(name2);

            testCategory2.Save();

            testCategory1.Delete();
            List <Category> resultCategories = Category.GetAll();
            List <Category> testCategoryList = new List <Category> {
                testCategory2
            };

            Assert.Equal(testCategoryList, resultCategories);
        }
Exemplo n.º 3
0
        public void Test_Delete_DeletesCategoryAssociationsFromDatabase()
        {
            //Arrange
              Task testTask = new Task("Mow the lawn", false);
              testTask.Save();

              string testName = "Home stuff";
              Category testCategory = new Category(testName);
              testCategory.Save();

              //Act
              testCategory.AddTask(testTask);
              testCategory.Delete();

              List<Category> resultTaskCategories = testTask.GetCategories();
              List<Category> testTaskCategories = new List<Category> {};

              //Assert
              Assert.Equal(testTaskCategories, resultTaskCategories);
        }
        public void Test_Delete_DeletesCategoryAssociationsFromDatabase()
        {
            DateTime date1    = new DateTime(2008, 4, 10);
            Task     testTask = new Task("Mow the lawn", date1);

            testTask.Save();

            string   testName     = "Home Stuff";
            Category testCategory = new Category(testName);

            testCategory.Save();

            testCategory.AddTask(testTask);
            testCategory.Delete();

            List <Category> resultTaskCategories = testTask.GetCategories();
            List <Category> testTaskCategories   = new List <Category> {
            };

            Assert.Equal(testTaskCategories, resultTaskCategories);
        }
Exemplo n.º 5
0
        public void Test_DeleteCategory_DeletesEntireCategory()
        {
            // Arrange
            Category newCategory = new Category("Kitchen");

            newCategory.Save();
            int targetId = newCategory.GetId();

            Task firstTask = new Task("Wash Dishes", "1999-01-01");

            firstTask.Save();
            Task secondTask = new Task("Empty Dishwasher", "2000-01-01");

            secondTask.Save();

            //Act
            newCategory.Delete();

            //Assert
            Assert.Equal(0, Category.GetAll().Count);
        }
Exemplo n.º 6
0
        public void Delete_DeletesCategoryAssociationsFromDatabase_CategoryList()
        {
            //Arrange
            Task testTask = new Task("Mow the lawn", true);

            testTask.Save();
            string   testName     = "Home stuff";
            Category testCategory = new Category(testName);

            testCategory.Save();

            //Act
            testCategory.AddTask(testTask);
            testCategory.Delete();

            List <Category> resultTaskCategories = testTask.GetCategories();
            List <Category> testTaskCategories   = new List <Category> {
            };

            //Assert
            Assert.Equal(testTaskCategories, resultTaskCategories);
        }
Exemplo n.º 7
0
        public void Test_Delete_DeletesCategoryFromDatabase()
        {
            //Arrange
            string   name1         = "Home stuff";
            Category testCategory1 = new Category(name1);

            testCategory1.Save();

            string   name2         = "Work stuff";
            Category testCategory2 = new Category(name2);

            testCategory2.Save();

            Task testTask1 = new Task("Mow the lawn", testCategory1.GetId());

            testTask1.Save();
            Task testTask2 = new Task("Send emails", testCategory2.GetId());

            testTask2.Save();

            //Act
            testCategory1.Delete();
            List <Category> resultCategories = Category.GetAll();
            List <Category> testCategoryList = new List <Category> {
                testCategory2
            };

            List <Task> resultTasks  = Task.GetAll();
            List <Task> testTaskList = new List <Task> {
                testTask2
            };

            //Assert
            Assert.Equal(testCategoryList, resultCategories);
            Assert.Equal(testTaskList, resultTasks);
        }
        public void Test_Delete_DeletesCategoryAssociationsFromDatabase()
        {
            //Arrange
              DateTime testTime = new DateTime(2016, 1, 1);

              Task testTask = new Task("Mow the lawn",testTime);
              testTask.Save();

              string testName = "Home stuff";
              Category testCategory = new Category(testName);
              testCategory.Save();

              //Act
              testCategory.AddTask(testTask);
              testCategory.Delete();

              List<Category> resultTaskCategories = testTask.GetCategories();
              List<Category> testTaskCategories = new List<Category> {};
              List<Task> resultsTasks= Task.GetAll();
              List<Task> testTasks= new List<Task>{testTask};

              //Assert
              Assert.Equal(testTaskCategories, resultTaskCategories);
              Assert.Equal(testTasks, resultsTasks);
        }
        public void T8_Delete_DeletesCategoryFromDatabase()
        {
            //Arrange
              string name1 = "Home stuff";
              Category testCategory1 = new Category(name1);
              testCategory1.Save();

              string name2 = "Work stuff";
              Category testCategory2 = new Category(name2);
              testCategory2.Save();

              //Act
              testCategory1.Delete();
              List<Category> resultCategories = Category.GetAll();
              List<Category> testCategoryList = new List<Category> {testCategory2};

              //Assert
              Assert.Equal(testCategoryList, resultCategories);
        }
Exemplo n.º 10
0
 public HomeModule()
 {
     Get["/"] = _ => {
         return(View["login.cshtml"]);
     };
     Post["/categories"] = _ => {
         Admin adminTest = new Admin(Request.Form["user-name"], Request.Form["user-password"]);
         bool  isAdmin   = adminTest.CheckPassword();
         if (isAdmin)
         {
             Admin.SetStatus(true);
             return(View["login.cshtml"]);
         }
         return(View["login.cshtml"]);
     };
     Get["/tasks"] = _ => {
         List <Task> AllTasks = Task.GetAll();
         return(View["tasks.cshtml", AllTasks]);
     };
     Get["/categories"] = _ => {
         Dictionary <string, object> model = new Dictionary <string, object>();
         var AllCategories = Category.GetAll();
         model.Add("categories", AllCategories);
         model.Add("accessTrue", Admin.GetStatus());
         return(View["categories.cshtml", model]);
     };
     Get["/categories/new"] = _ => {
         return(View["categories_form.cshtml"]);
     };
     Post["/categories/new"] = _ => {
         Category newCategory = new Category(Request.Form["category-name"]);
         newCategory.Save();
         return(View["success.cshtml"]);
     };
     Get["/tasks/new"] = _ => {
         List <Category> AllCategories = Category.GetAll();
         return(View["tasks_form.cshtml", AllCategories]);
     };
     Post["/tasks/new"] = _ => {
         Task newTask = new Task(Request.Form["task-description"], Request.Form["task-duedate"], Request.Form["category-id"]);
         newTask.Save();
         return(View["success.cshtml"]);
     };
     Post["/tasks/delete"] = _ => {
         Task.DeleteAll();
         return(View["cleared.cshtml"]);
     };
     Get["/categories/{id}"] = parameters => {
         Dictionary <string, object> model = new Dictionary <string, object>();
         var SelectedCategory = Category.Find(parameters.id);
         var CategoryTasks    = SelectedCategory.GetTasks();
         model.Add("category", SelectedCategory);
         model.Add("tasks", CategoryTasks);
         return(View["category.cshtml", model]);
     };
     Get["category/edit/{id}"] = parameters => {
         Category SelectedCategory = Category.Find(parameters.id);
         return(View["category_edit.cshtml", SelectedCategory]);
     };
     Patch["category/edit/{id}"] = parameters => {
         Category SelectedCategory = Category.Find(parameters.id);
         SelectedCategory.Update(Request.Form["category-name"]);
         return(View["success.cshtml"]);
     };
     Get["category/delete/{id}"] = parameters => {
         Category SelectedCategory = Category.Find(parameters.id);
         return(View["category_delete.cshtml", SelectedCategory]);
     };
     Delete["category/delete/{id}"] = parameters => {
         Category SelectedCategory = Category.Find(parameters.id);
         SelectedCategory.Delete();
         return(View["success.cshtml"]);
     };
 }
Exemplo n.º 11
0
        public HomeModule()
        {
            Get["/"] = _ => {
                List <Category> AllCategories = Category.GetAll();
                return(View["index.cshtml", AllCategories]);
            };

            Get["/tasks"] = _ => {
                List <Task> AllTasks = Task.GetAll();
                return(View["tasks.cshtml", AllTasks]);
            };

            Get["/categories"] = _ => {
                List <Category> AllCategories = Category.GetAll();
                return(View["categories.cshtml", AllCategories]);
            };

            Get["/categories/new"] = _ => {
                return(View["categories_form.cshtml"]);
            };
            Post["/categories/new"] = _ => {
                Category newCategory = new Category(Request.Form["category-name"]);
                newCategory.Save();
                return(View["success.cshtml"]);
            };
            Get["/tasks/new"] = _ => {
                List <Category> AllCategories = Category.GetAll();
                return(View["tasks_form.cshtml", AllCategories]);
            };
            Post["/tasks/new"] = _ => {
                Task newTask = new Task(Request.Form["task-description"], Request.Form["category-id"]);
                newTask.Save();
                return(View["success.cshtml"]);
            };

            Post["/tasks/delete"] = _ => {
                Task.DeleteAll();
                return(View["cleared.cshtml"]);
            };
            Get["/categories/{id}"] = parameters => {
                Dictionary <string, object> model = new Dictionary <string, object>();
                var SelectedCategory = Category.Find(parameters.id);
                var CategoryTasks    = SelectedCategory.GetTasks();
                model.Add("category", SelectedCategory);
                model.Add("tasks", CategoryTasks);
                return(View["category.cshtml", model]);
            };

            Get["category/edit/{id}"] = parameters => {
                Category SelectedCategory = Category.Find(parameters.id);
                return(View["category_edit.cshtml", SelectedCategory]);
            };

            Patch["category/edit/{id}"] = parameters => {
                Category SelectedCategory = Category.Find(parameters.id);
                SelectedCategory.Update(Request.Form["category-name"]);
                return(View["success.cshtml"]);
            };


            Get["category/delete/{id}"] = parameters => {
                Category SelectedCategory = Category.Find(parameters.id);
                return(View["category_delete.cshtml", SelectedCategory]);
            };
            Delete["category/delete/{id}"] = parameters => {
                Category SelectedCategory = Category.Find(parameters.id);
                SelectedCategory.Delete();
                return(View["success.cshtml"]);
            };
        }
Exemplo n.º 12
0
        public HomeModule()
        {
            Get["/"] = _ => {
                Dictionary <string, object> passedModel = new Dictionary <string, object>()
                {
                };
                passedModel["categories"] = Category.GetAll();
                passedModel["tasks"]      = Task.GetAll();
                return(View["index.cshtml", passedModel]);
            };
            Get["/tasks"] = _ => {
                List <Task> AllTasks = Task.GetAll();
                return(View["tasks.cshtml", AllTasks]);
            };
            Get["/categories"] = _ => {
                List <Category> AllCategories = Category.GetAll();
                return(View["categories.cshtml", AllCategories]);
            };

            //Create a new task
            Get["/tasks/new"] = _ => {
                return(View["tasks_form.cshtml"]);
            };
            Post["/tasks/new"] = _ => {
                Task newTask = new Task(Request.Form["task-description"], Request.Form["date"]);
                newTask.Save();
                Dictionary <string, object> passedModel = new Dictionary <string, object>()
                {
                };
                passedModel["categories"] = Category.GetAll();
                passedModel["tasks"]      = Task.GetAll();
                return(View["index.cshtml", passedModel]);
            };

            //Create a new category
            Get["/categories/new"] = _ => {
                return(View["categories_form.cshtml"]);
            };
            Post["/categories/new"] = _ => {
                Category newCategory = new Category(Request.Form["category-name"]);
                newCategory.Save();
                Dictionary <string, object> passedModel = new Dictionary <string, object>()
                {
                };
                passedModel["categories"] = Category.GetAll();
                passedModel["tasks"]      = Task.GetAll();
                return(View["index.cshtml", passedModel]);
            };

            Get["tasks/{id}"] = parameters =>
            {
                Dictionary <string, object> passedModel = new Dictionary <string, object>()
                {
                };
                Task            targetTask     = Task.Find(parameters.id);
                List <Category> taskCategories = targetTask.GetCategories();
                List <Category> allCategories  = Category.GetAll();
                passedModel.Add("task", targetTask);
                passedModel.Add("taskCategories", taskCategories);
                passedModel.Add("allCategories", allCategories);
                return(View["task.cshtml", passedModel]);
            };
            Delete["tasks/{id}"] = parameters =>
            {
                Task targetTask = Task.Find(parameters.id);
                targetTask.Delete();
                Dictionary <string, object> passedModel = new Dictionary <string, object>()
                {
                };
                passedModel["categories"] = Category.GetAll();
                passedModel["tasks"]      = Task.GetAll();
                return(View["index.cshtml", passedModel]);
            };
            Patch["/tasks/{id}"] = parameters =>
            {
                string newName = Request.Form["new-task-name"];
                string newDate = Request.Form["new-task-date"];
                Task.Find(parameters.id).Update(newName, newDate);
                Dictionary <string, object> passedModel = new Dictionary <string, object>()
                {
                };
                passedModel["categories"] = Category.GetAll();
                passedModel["tasks"]      = Task.GetAll();
                return(View["index.cshtml", passedModel]);
            };

            Get["categories/{id}"] = parameters =>
            {
                Dictionary <string, object> passedModel = new Dictionary <string, object>()
                {
                };
                Category    targetCategory = Category.Find(parameters.id);
                List <Task> categoryTasks  = targetCategory.GetTasks();
                List <Task> allTasks       = Task.GetAll();
                passedModel.Add("category", targetCategory);
                passedModel.Add("categoryTasks", categoryTasks);
                passedModel.Add("allTasks", allTasks);
                return(View["category.cshtml", passedModel]);
            };
            Delete["categories/{id}"] = parameters =>
            {
                Category targetCategory = Category.Find(parameters.id);
                targetCategory.Delete();
                Dictionary <string, object> passedModel = new Dictionary <string, object>()
                {
                };
                passedModel["categories"] = Category.GetAll();
                passedModel["tasks"]      = Task.GetAll();
                return(View["index.cshtml", passedModel]);
            };
            Patch["/categories/{id}"] = parameters =>
            {
                string newName = Request.Form["new-category-name"];
                Category.Find(parameters.id).Update(newName);
                Dictionary <string, object> passedModel = new Dictionary <string, object>()
                {
                };
                passedModel["categories"] = Category.GetAll();
                passedModel["tasks"]      = Task.GetAll();
                return(View["index.cshtml", passedModel]);
            };

            Post["task/add_category"] = _ => {
                Category category = Category.Find(Request.Form["category-id"]);
                Task     task     = Task.Find(Request.Form["task-id"]);
                task.AddCategory(category);
                Dictionary <string, object> passedModel = new Dictionary <string, object>()
                {
                };
                passedModel["categories"] = Category.GetAll();
                passedModel["tasks"]      = Task.GetAll();
                return(View["index.cshtml", passedModel]);
            };
            Post["category/add_task"] = _ => {
                Category category = Category.Find(Request.Form["category-id"]);
                Task     task     = Task.Find(Request.Form["task-id"]);
                category.AddTask(task);
                Dictionary <string, object> passedModel = new Dictionary <string, object>()
                {
                };
                passedModel["categories"] = Category.GetAll();
                passedModel["tasks"]      = Task.GetAll();
                return(View["index.cshtml", passedModel]);
            };
            //
            // Get["/categories"] = _ => {
            //   var allCategories = Category.GetAll();
            //   return View["categories.cshtml", allCategories];
            // };
            // Post["/categories"] = _ => {
            //   var newCategory = new Category(Request.Form["category-name"]);
            //   newCategory.Save();
            //   var allCategories = Category.GetAll();
            //   return View["categories.cshtml", allCategories];
            // };
            //
            // Get["/categories/new"] = _ => {
            //   return View["category_form.cshtml"];
            // };
            //
            // Get["/categories/{id}"] = parameters => {
            //   Dictionary<string, object> model = new Dictionary<string, object>();
            //   var selectedCategory = Category.Find(parameters.id);
            //   var categoryTasks = selectedCategory.GetTasks();
            //   model.Add("category", selectedCategory);
            //   model.Add("tasks", categoryTasks);
            //   return View["category.cshtml", model];
            // };
            //
            // Get["/categories/{id}/tasks/new"] = parameters => {
            //   Dictionary<string, object> model = new Dictionary<string, object>();
            //   Category selectedCategory = Category.Find(parameters.id);
            //   List<Task> allTasks = selectedCategory.GetTasks();
            //   model.Add("category", selectedCategory);
            //   model.Add("tasks", allTasks);
            //   return View["category_tasks_form.cshtml", model];
            // };
            //
            // Post["/delete/task/{categoryId}/{taskId}"] = parameters => {
            //     Task targetTask = Task.Find(parameters.taskId);
            //     targetTask.Delete();
            //     Dictionary<string, object> model = new Dictionary<string, object>();
            //     var selectedCategory = Category.Find(parameters.categoryId);
            //     var categoryTasks = selectedCategory.GetTasks();
            //     model.Add("category", selectedCategory);
            //     model.Add("tasks", categoryTasks);
            //     return View["category.cshtml", model];
            // };
            //
            // Post["/delete/category/{categoryId}"] = parameters => {
            //     Category targetCategory = Category.Find(parameters.categoryId);
            //     targetCategory.Delete();
            //     List<Category> allCategories = Category.GetAll();
            //     return View["categories.cshtml", allCategories];
            // };
            //
            // Post["/tasks"] = _ => {
            //   Dictionary<string, object> model = new Dictionary<string, object>();
            //   Category selectedCategory = Category.Find(Request.Form["category-id"]);
            //   string taskDescription = Request.Form["task-description"];
            //   int newCategoryId = int.Parse(Request.Form["category-id"]);
            //   string newDate = Request.Form["date"];
            //   Task newTask = new Task(taskDescription, newCategoryId, newDate);
            //   newTask.Save();
            //   List<Task> categoryTasks = selectedCategory.GetTasks();
            //   model.Add("tasks", categoryTasks);
            //   model.Add("category", selectedCategory);
            //   return  View["category.cshtml", model];
            // };
        }
Exemplo n.º 13
0
 public HomeModule()
 {
     Get["/"] = _ => {
         List <Category> AllCategories = Category.GetAll();
         return(View["index.cshtml", AllCategories]);
     };
     Get["/tasks"] = _ => {
         List <Task> AllTasks = Task.GetAll();
         return(View["tasks.cshtml", AllTasks]);
     };
     Get["/categories"] = _ => {
         List <Category> AllCategories = Category.GetAll();
         return(View["categories.cshtml", AllCategories]);
     };
     Get["/categories/new"] = _ => {
         return(View["categories_form.cshtml"]);
     };
     Post["/categories/new"] = _ => {
         Category newCategory = new Category(Request.Form["category-name"]);
         newCategory.Save();
         return(View["success.cshtml"]);
     };
     Get["/tasks/new"] = _ => {
         List <Category> AllCategories = Category.GetAll();
         return(View["tasks_form.cshtml", AllCategories]);
     };
     Post["/tasks/new"] = _ => {
         Task newTask = new Task(Request.Form["task-description"], Request.Form["task-date"]);
         newTask.Save();
         return(View["success.cshtml"]);
     };
     Post["/tasks/delete"] = _ => {
         Task.DeleteAll();
         return(View["tasks_cleared.cshtml"]);
     };
     Post["/categories/clear"] = _ => {
         Category.DeleteAll();
         Task.DeleteAll();
         return(View["categories_cleared.cshtml"]);
     };
     Get["/tasks/{id}"] = parameters => {
         Dictionary <string, object> model = new Dictionary <string, object>();
         Task            SelectedTask      = Task.Find(parameters.id);
         List <Category> TaskCategories    = SelectedTask.GetCategories();
         List <Category> AllCategories     = Category.GetAll();
         model.Add("task", SelectedTask);
         model.Add("taskCategories", TaskCategories);
         model.Add("allCategories", AllCategories);
         return(View["task.cshtml", model]);
     };
     Get["/categories/{id}"] = parameters => {
         Dictionary <string, object> model = new Dictionary <string, object>();
         Category    SelectedCategory      = Category.Find(parameters.id);
         List <Task> CategoryTasks         = SelectedCategory.GetTasks();
         List <Task> AllTasks = Task.GetAll();
         model.Add("category", SelectedCategory);
         model.Add("categoryTasks", CategoryTasks);
         model.Add("allTasks", AllTasks);
         return(View["category.cshtml", model]);
     };
     Patch["/categories/finished/{id}"] = parameters => {
         Task isTaskDone = Task.Find(parameters.id);
         isTaskDone.UpdateDone(1);
         return(View["index.cshtml"]);
     };
     Post["/task/add_category"] = _ => {
         Category category = Category.Find(Request.Form["category-id"]);
         Task     task     = Task.Find(Request.Form["task-id"]);
         task.AddCategory(category);
         return(View["success.cshtml"]);
     };
     Post["/category/add_task"] = _ => {
         Category category = Category.Find(Request.Form["category-id"]);
         Task     task     = Task.Find(Request.Form["task-id"]);
         category.AddTask(task);
         return(View["success.cshtml"]);
     };
     // Get["/category/list"] = _ => {
     //     Console.WriteLine(Request.Query("house work"));
     //     Dictionary<string, object> model = new Dictionary<string, object>();
     //     List<Category> allCategories = Category.GetAll();
     //     foreach(var category in allCategories)
     //     {
     //         if(Request.Form[category.GetName()] != null)
     //         {
     //             List<Task> listTasks = category.GetTasks();
     //             model.Add(category.GetName(), listTasks);
     //         }
     //     }
     //     foreach(KeyValuePair<string, object> entry in model)
     //     {
     //         foreach(Task thisTask in entry.Value as List<Task>)
     //         {
     //             Console.WriteLine(thisTask.GetDescription());
     //         }
     //     }
     //     return View["categories_multiple.cshtml", model];
     // };
     Get["/category/edit/{id}"] = parameters => {
         Category SelectedCategory = Category.Find(parameters.id);
         return(View["category_edit.cshtml", SelectedCategory]);
     };
     Patch["/category/edit/{id}"] = parameters => {
         Category SelectedCategory = Category.Find(parameters.id);
         SelectedCategory.Update(Request.Form["category-name"]);
         return(View["success.cshtml"]);
     };
     Get["/category/delete/{id}"] = parameters => {
         Category SelectedCategory = Category.Find(parameters.id);
         return(View["category_delete.cshtml", SelectedCategory]);
     };
     Delete["/category/delete/{id}"] = parameters => {
         Category SelectedCategory = Category.Find(parameters.id);
         SelectedCategory.Delete();
         return(View["success.cshtml"]);
     };
 }
Exemplo n.º 14
0
        public HomeModule()
        {
            Get["/"] = _ => {
                return(View["index.cshtml"]);
            }; //homepage with links to view all tasks and all categories
            Get["/tasks"] = _ => {
                List <Task> AllTasks = Task.GetAll();
                return(View["tasks.cshtml", AllTasks]);
            }; //page view all tasks
            Get["/categories"] = _ => {
                List <Category> AllCategories = Category.GetAll();
                return(View["categories.cshtml", AllCategories]);
            }; //page view all categories
            Get["/categories/new"] = _ => {
                return(View["categories_form.cshtml"]);
            };
            Get["/tasks/new"] = _ => {
                return(View["tasks_form.cshtml"]);
            }; //returns form to add new task
            Post["/tasks/new"] = _ => {
                Task newTask = new Task(Request.Form["task-description"], Request.Form["category-id"]);
                newTask.Save();
                List <Task> AllTasks = Task.GetAll();
                return(View["tasks.cshtml", AllTasks]);
            }; //posts from form adding new task
            Get["/categories/new"] = _ => {
                return(View["categories_form.cshtml"]);
            }; //returns form to add new task
            Post["/categories/new"] = _ => {
                Category newCategory = new Category(Request.Form["category-name"]);
                newCategory.Save();
                List <Category> AllCategories = Category.GetAll();
                return(View["categories.cshtml", AllCategories]);
            }; //posts from form adding new category
            Get["/tasks/{id}"] = parameters => {
                Dictionary <string, object> model = new Dictionary <string, object>();
                Task            SelectedTask      = Task.Find(parameters.id);
                List <Category> TaskCategories    = SelectedTask.GetCategories();
                List <Category> AllCategories     = Category.GetAll();
                model.Add("task", SelectedTask);
                model.Add("taskCategories", TaskCategories);
                model.Add("allCategories", AllCategories);
                model.Add("isCompleted", SelectedTask);
                return(View["task.cshtml", model]);
            }; //returns individual instance of task
            Get["/categories/{id}"] = parameters => {
                Dictionary <string, object> model = new Dictionary <string, object>();
                Category    SelectedCategory      = Category.Find(parameters.id);
                List <Task> CategoryTasks         = SelectedCategory.GetTasks();
                List <Task> AllTasks = Task.GetAll();
                model.Add("category", SelectedCategory);
                model.Add("categoryTasks", CategoryTasks);
                model.Add("allTasks", AllTasks);
                return(View["category.cshtml", model]);
            }; //returns individual instance of category
            Post["/task/{id}/add_category"] = parameters => {
                Category category = Category.Find(Request.Form["category-id"]);
                Task     task     = Task.Find(Request.Form["task-id"]);
                task.AddCategory(category);
                Dictionary <string, object> model          = new Dictionary <string, object>();
                List <Category>             taskCategories = task.GetCategories();
                List <Category>             allCategories  = Category.GetAll();
                model.Add("task", task);
                model.Add("taskCategories", taskCategories);
                model.Add("allCategories", allCategories);
                model.Add("isCompleted", task);
                return(View["index.cshtml", model]);
            }; //posts from form adding category
            Post["/category/{id}/add_task"] = parameters => {
                Category category = Category.Find(Request.Form["category-id"]);
                Task     task     = Task.Find(Request.Form["task-id"]);
                category.AddTask(task);
                Dictionary <string, object> model = new Dictionary <string, object>();
                Category    SelectedCategory      = Category.Find(parameters.id);
                List <Task> CategoryTasks         = SelectedCategory.GetTasks();
                List <Task> AllTasks = Task.GetAll();
                model.Add("category", SelectedCategory);
                model.Add("categoryTasks", CategoryTasks);
                model.Add("allTasks", AllTasks);
                return(View["category.cshtml", model]);
            }; //posts from form adding task to category page
            Get["/task/{id}/completed"] = parameters => {
                Dictionary <string, object> model = new Dictionary <string, object> {
                };
                Task   SelectedTask  = Task.Find(parameters.id);
                string taskCompleted = Request.Query["task-completed"];
                model.Add("form-type", taskCompleted);
                model.Add("task", SelectedTask);
                return(View["completed.cshtml", model]);
            }; //returns page confirming task completion

            Patch["/task/{id}/completed"] = parameters => {
                Dictionary <string, object> model = new Dictionary <string, object>();
                Task            SelectedTask      = Task.Find(parameters.id);
                List <Category> TaskCategories    = SelectedTask.GetCategories();
                List <Category> AllCategories     = Category.GetAll();
                SelectedTask.Update(true);
                model.Add("task", SelectedTask);
                model.Add("taskCategories", TaskCategories);
                model.Add("allCategories", AllCategories);
                model.Add("isCompleted", SelectedTask);
                return(View["task.cshtml", model]);
            }; //returns category page with task marked completed

            Get["/category/edit/{id}"] = parameters => {
                Category SelectedCategory = Category.Find(parameters.id);
                return(View["category_edit.cshtml", SelectedCategory]);
            }; //edit individual category
            Patch["/category/edit/{id}"] = parameters => {
                Dictionary <string, object> model = new Dictionary <string, object>();
                Category SelectedCategory         = Category.Find(parameters.id);
                SelectedCategory.Update(Request.Form["category-name"]);
                List <Task> CategoryTasks = SelectedCategory.GetTasks();
                List <Task> AllTasks      = Task.GetAll();
                model.Add("category", SelectedCategory);
                model.Add("categoryTasks", CategoryTasks);
                model.Add("allTasks", AllTasks);
                return(View["category.cshtml", model]);
            }; //posts from editing individual category
            Get["/category/delete/{id}"] = parameters => {
                Category SelectedCategory = Category.Find(parameters.id);
                return(View["category_delete.cshtml", SelectedCategory]);
            }; //delete individual category
            Delete["/category/delete/{id}"] = parameters => {
                Category SelectedCategory = Category.Find(parameters.id);
                SelectedCategory.Delete();
                List <Category> AllCategories = Category.GetAll();
                return(View["categories.cshtml", AllCategories]);
            }; //delete individual category
        }