public void Test_AddCategory_AddsCategoryToTask() { //Arrange Task testTask = new Task("Mow the lawn", new DateTime(2016, 2, 2), false); testTask.Save(); Category testCategory = new Category("Home stuff"); testCategory.Save(); //Act testTask.AddCategory(testCategory); List<Category> result = testTask.GetCategories(); List<Category> testList = new List<Category>{testCategory}; //Assert Assert.Equal(testList, result); }
public void Test18_GetCategories_ReturnsAllTaskCategories() { DateTime testTime = new DateTime(2016, 1, 1); Task testTask = new Task("Mow the lawn",testTime); testTask.Save(); Category testCategory1 = new Category("Home Stuff"); testCategory1.Save(); Category testCategory2 = new Category("Work Stuff"); testCategory2.Save(); testTask.AddCategory(testCategory1); List<Category> result = testTask.GetCategories(); List<Category> testList= new List<Category>{testCategory1}; Assert.Equal(testList,result); }
public void Test_Delete_DeletesTaskAssociationsFromDatabase() { //Arrange Category testCategory = new Category("Home stuff"); testCategory.Save(); string testDescription = "Mow the lawn"; Task testTask = new Task(testDescription, new DateTime(2016, 2, 2)); testTask.Save(); //Act testTask.AddCategory(testCategory); testTask.Delete(); List<Task> resultCategoryTasks = testCategory.GetTasks(); List<Task> testCategoryTasks = new List<Task> {}; //Assert Assert.Equal(testCategoryTasks, resultCategoryTasks); }
public void Test_Delete_DeletesTaskAssociationsFromDatabase() { //Arrange Category testCategory = new Category("Home stuff"); testCategory.Save(); string testDescription = "Mow the lawn"; bool testComplete = false; Task testTask = new Task(testDescription, testComplete); testTask.Save(); //Act testTask.AddCategory(testCategory); testTask.Delete(); List <Task> resultCategoryTasks = testCategory.GetTasks(); List <Task> testCategoryTasks = new List <Task> { }; //Assert Assert.Equal(testCategoryTasks, resultCategoryTasks); }
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["dueDate"], Request.Form["completed"]); newTask.Save(); return(View["success.cshtml"]); }; Post["/tasks/delete"] = _ => { Task.DeleteAll(); return(View["index.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>(); var SelectedCategory = Category.Find(parameters.id); var CategoryTasks = SelectedCategory.GetTasks(); List <Task> AllTasks = Task.GetAll(); model.Add("category", SelectedCategory); model.Add("tasks", CategoryTasks); model.Add("allTasks", AllTasks); return(View["category.cshtml", model]); }; 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["tasks/completed"] = _ => { List <Task> updatedTasks = Task.CompletedTasks(); return(View["completed_tasks.cshtml", updatedTasks]); }; Get["tasks/update/{id}"] = _ => { List <Task> updatedTasks = Task.CompletedTasks(); return(View["completed_tasks.cshtml", updatedTasks]); }; Patch["tasks/update/{id}"] = parameters => { Task completedTask = Task.Find(parameters.id); completedTask.MarkComplete(); List <Task> updatedTasks = Task.CompletedTasks(); return(View["completed_tasks.cshtml", updatedTasks]); }; Post["/tasks/sorted"] = _ => { List <Task> AllTasks = Task.OrderByDate(); return(View["tasks.cshtml", AllTasks]); }; }
public void Test_GetCategories_ReturnsAllTaskCategories() { //Arrange Task testTask = new Task("Mow the lawn"); testTask.Save(); Category testCategory1 = new Category("Home stuff"); testCategory1.Save(); Category testCategory2 = new Category("Work stuff"); testCategory2.Save(); //Act testTask.AddCategory(testCategory1); List<Category> result = testTask.GetCategories(); List<Category> testList = new List<Category> {testCategory1}; //Assert Assert.Equal(testList, result); }
public void Test_Delete_DeletesTaskFromDatabase() { //Arrange Category testCategory = new Category("Home stuff"); testCategory.Save(); string description1 = "Mow the lawn"; Task testTask1 = new Task(description1); testTask1.Save(); string description2 = "Do homework"; Task testTask2 = new Task(description2); testTask2.Save(); //Act testTask1.AddCategory(testCategory); testTask1.Delete(); List<Task> resultTasks = Task.GetAll(); List<Task> testTaskList = new List<Task> {testTask2}; List<Task> resultCategoryTasks = testCategory.GetTasks(); List<Task> testCategoryTasks = new List<Task> {}; //Assert Assert.Equal(testTaskList, resultTasks); Assert.Equal(testCategoryTasks, resultCategoryTasks); }
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"], new DateTime(Request.Form["due-date"])); newTask.Save(); return(View["success.cshtml"]); }; Delete["/tasks/delete"] = _ => { Task.DeleteAll(); return(View["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]); }; 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["/tasks/complete"] = _ => { List <Task> completedTasks = Task.GetAll(true); return(View["tasks.cshtml", completedTasks]); }; Get["/tasks/incomplete"] = _ => { List <Task> incompleteTasks = Task.GetAll(false); return(View["tasks.cshtml", incompleteTasks]); }; Patch["/tasks/{id}/complete"] = parameters => { Task.Complete(parameters.id); List <Task> allTasks = Task.GetAll(); return(View["tasks.cshtml", allTasks]); // List<Category> AllCategories = Category.GetAll(); // return View["index.cshtml", AllCategories]; }; }
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"] = _ => { string date = Request.Form["task-date"]; Console.WriteLine(date); 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["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]); }; Post["/categories/delete"] = _ => { Category.DeleteAll(); Task.DeleteAll(); return(View["cleared.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"]); }; }
public HomeModule() { Get["/"] = _ => { return(View["index.cshtml"]); }; Get["/tasks"] = _ => { List <Task> AllTasks = Task.GetAll(); return(View["tasks.cshtml", AllTasks]); }; Post["/tasks"] = _ => { Dictionary <string, object> model = new Dictionary <string, object>(); Category selectedCategory = Category.Find(Request.Form["category-id"]); List <Task> categoryTasks = selectedCategory.GetTasks(); string taskDescription = Request.Form["task-description"]; Task newTask = new Task(taskDescription); categoryTasks.Add(newTask); model.Add("tasks", categoryTasks); model.Add("category", selectedCategory); return(View["category.cshtml", model]); }; 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"]); newTask.Save(); return(View["success.cshtml"]); }; //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(); return(View["success.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["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]); }; 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]); }; }
public HomeModule() { Get["/"] = _ => { return(View["index.cshtml"]); }; 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"] = _ => { return(View["tasks_form.cshtml"]); }; Post["/tasks/new"] = _ => { Task newTask = new Task(Request.Form["task-description"], Request.Form["due-date"]); 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>(); 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]); }; 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]); }; Post["task/add_category"] = _ => { Category category = Category.Find(Request.Form["category-id"]); Task task = Task.Find(Request.Form["task-id"]); List <Category> taskCategories = task.GetCategories(); bool tracker = false; foreach (Category thisCategory in taskCategories) { if (category.GetName() == thisCategory.GetName()) { tracker = true; } } if (!tracker) { 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"]); }; }
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]; // }; }
public HomeModule() { Get["/"] = _ => { return(View["index.cshtml"]); }; Get["/tasks"] = _ => { List <Task> AllTasks = Task.GetAll(); return(View["tasks.cshtml", AllTasks]); }; Get["/tasks/completed"] = _ => { List <Task> CompletedTasks = Task.GetCompleted(); return(View["tasks_completed.cshtml", CompletedTasks]); }; Get["/categories"] = _ => { List <Category> AllCategories = Category.GetAll(); return(View["categories.cshtml", AllCategories]); }; //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(); return(View["success.cshtml"]); }; //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["completed"]); newTask.Save(); return(View["success.cshtml"]); }; Post["/tasks/delete"] = _ => { Task.DeleteAll(); return(View["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]); }; 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["tasks/{id}/edit"] = parameters => { Task SelectedTask = Task.Find(parameters.id); return(View["task_update_form.cshtml", SelectedTask]); }; Patch["tasks/{id}/updated"] = parameters => { Task SelectedTask = Task.Find(parameters.id); SelectedTask.UpdateProperties(Request.Form["new-task-description"], Request.Form["new-completed"]); return(View["success.cshtml", SelectedTask]); }; Post["/tasks/delete"] = _ => { Task.DeleteAll(); return(View["success.cshtml"]); }; }
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"]); }; }
public HomeModule() { Get["/"] = _ => { return(View["index.cshtml"]); }; 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["/tasks/new"] = _ => { return(View["tasks_form.cshtml"]); }; Post["/tasks/new"] = _ => { Task newTask = new Task(Request.Form["task-description"]); newTask.Save(); return(View["success.cshtml"]); }; //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(); return(View["success.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]); }; 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["/categories/new"] = _ => { // return View["categories_form.cshtml"]; // }; // Post["/categories/new"] = _ => { // Category newCategory = new Category(Request.Form["category-name"]); // newCategory.Save(); // return View["success.cshtml"]; // }; // Post["/categories/clear"] = _ => { // Category.DeleteAll(); // // return View["cleared.cshtml"]; no cleared.cshtml in lesson plan, switched to success.cshtml // return View["success.cshtml"]; // }; // 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"]; // }; // 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/clear"] = _ => { // Task.DeleteAll(); // return View["success.cshtml"]; // // return View["cleared.cshtml"]; no cleared.cshtml in lesson plan, switched to success.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]; // }; }
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 }