public void T7_Update_UpdatesCategoryInDatabase() { //Arrange string name = "Home Chores"; Category testCategory = new Category(name); testCategory.Save(); string newName = "Work Chores"; //Act testCategory.Update(newName); string result = testCategory.GetName(); //Assert Assert.Equal(newName, result); }
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"]); }; }
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["/"] = _ => { 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"]); }; }
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 }