public HomeModule()
        {
            Get["/"] = _ => {
                return(View["index.cshtml"]);
            };

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

            Get["/tasks/new"] = _ => {
                return(View["add_new_task"]);
            };

            Post["/tasks/added"] = _ => {
                Task newTask = new Task(Request.Form["description"]);
                newTask.Save();
                return(View["task_created.cshtml", newTask]);
            };

            Get["/tasks/{id}"] = parameters => {
                Task selectedTask = Task.Find(parameters.id);
                return(View["task_details.cshtml", selectedTask]);
            };

            Get["/tasks/cleared"] = _ => {
                Task.DeleteAll();
                return(View["tasks_deleted.cshtml"]);
            };
        }
        public void Dispose()
        {
            //    Console.WriteLine("categories");
            Category.DeleteAll();
            Task.DeleteAll();
//      Console.WriteLine(Task.GetAll().Count);
//      Console.WriteLine(Category.GetAll().Count);
        }
Esempio n. 3
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"], 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>();
                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"]);
     };
     Get["/categories"] = _ => {
         var allCategories = Category.GetAll();
         return(View["categories.cshtml", allCategories]);
     };
     Get["/categories/new"] = _ => {
         return(View["category_form.cshtml"]);
     };
     Post["/categories"] = _ => {
         var newCategory = new Category(Request.Form["category-name"]);
         newCategory.Save();
         var allCategories = Category.GetAll();
         return(View["categories.cshtml", allCategories]);
     };
     Get["/categories/{id}"] = parameters => {
         var         selectedCategory = Category.Find(parameters.id);
         List <Task> categoryTasks    = selectedCategory.GetTasks();
         return(View["category.cshtml", selectedCategory]);
     };
     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["/tasks"] = _ => {
         Category selectedCategory   = Category.Find(Request.Form["category-id"]);
         int      selectedCategoryId = selectedCategory.GetId();
         string   taskDescription    = Request.Form["task-description"];
         DateTime taskDue            = Request.Form["task-due"];
         Task     newTask            = new Task(taskDescription, selectedCategoryId, taskDue);
         newTask.Save();
         List <Task> categoryTasks = selectedCategory.GetTasks();
         return(View["category.cshtml", selectedCategory]);
     };
     Post["/"] = _ => {
         Task.DeleteAll();
         Category.DeleteAll();
         return(View["index.cshtml"]);
     };
 }
Esempio n. 5
0
 public HomeModule()
 {
     Get["/"] = _ => {
         return(View["index.cshtml"]);
     };
     Post["/task_added"] = _ => {
         var NewTask = new Task(Request.Form["new-task"]);
         NewTask.Save();
         return(View["task_added.cshtml", NewTask]);
     };
     Get["/view_all_tasks"] = _ => {
         var AllTasks = Task.ListOfTasks;
         return(View["view_all_tasks.cshtml", AllTasks]);
     };
     Post["/tasks_cleared"] = _ => {
         Task.DeleteAll();
         return(View["tasks_cleared.cshtml"]);
     };
 }
Esempio n. 6
0
 public void Dispose()
 {
     Task.DeleteAll();
     Category.DeleteAll();
 }
Esempio n. 7
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["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]);
            };
        }
Esempio n. 8
0
 public void Dispose()
 {
     System.Console.WriteLine("Dispose function called");
     Task.DeleteAll();
 }
Esempio n. 9
0
 public void Dispose()
 {
     Task.DeleteAll();
 }
Esempio 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"]);
     };
 }
Esempio 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"], 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];
            };
        }
Esempio n. 12
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"]);
     };
 }
        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["/"] = _ => {
                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["/"] = _ => {
            //         return View["index.cshtml"];
            //       };
            //       //Displays the list of the categories (returns the list called instances)
            //       Get["/all_categories"] = _ => {
            //         var allCategories = Category.GetAll();
            //         return View["all_categories.cshtml", allCategories];
            //       };
            //       //When we select "Add a new category" on the index page, open the category form page
            //       Get["/all_categories/new"] = _ => {
            //         return View["category_form.cshtml"];
            //       };
            //       //Takes info from the form and makes it into a new object. Then we get all of the category objects and show them all on the page
            //       Post["/all_categories"] = _ => {
            //         var newCategory = new Category(Request.Form["category-name"]);
            //         var allCategories = Category.GetAll();
            //         return View["all_categories.cshtml", allCategories];
            //       };
            //       //List of all of the tasks in a single category
            //       //Creates a dictionary with the key as either a 'categry' or a 'task', and the value as the applicable value and task
            //       Get["/all_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];
            //       };
            //       //Adding a task to a selected category
            //       //Displays the form to add a task to that category
            //       Get["/all_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];
            //       };
            //       //list of all the tasks in a single category
            //       Post["/tasks"] = _ => {
            //         Dictionary<string, object> model = new Dictionary<string, object>();
            //         Category selectedCategory = Category.Find(Request.Form["category-id"]);//strongly typed
            //         List<Task> categoryTasks = selectedCategory.GetTasks();// strongly typed. Both are just a different way to type var SelecteCategory etc from previous Get method.
            //         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];
            //       };
            //
        }
Esempio n. 15
0
        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"]);
            };
        }
Esempio n. 16
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"] = _ => {
                int      year    = Request.Form["year"];
                int      month   = Request.Form["month"];
                int      day     = Request.Form["day"];
                DateTime newDate = new DateTime(year, month, day);

                Task newTask = new Task(Request.Form["task-description"]);
                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"]);
            };
        }
Esempio n. 17
0
        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"]);
            };
        }
Esempio n. 18
0
        public HomeModule()
        {
            //Index
            Get["/"] = _ => {
                List <Category> AllCategories = Category.GetAll();
                return(View["index.cshtml", AllCategories]);
            };

            //Get: Lists
            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 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 new task
            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"]);
            };

            //"Clear All" routes
            Post["/tasks/clear"] = _ => {
                Task.DeleteAll();
                return(View["cleared.cshtml"]);
            };
            Post["/categories/clear"] = _ => {
                Category.DeleteAll();
                return(View["cleared.cshtml"]);
            };

            //View specific category
            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]);
            };

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

            //Delete specific category
            Get["category/delete/{id}"] = parameters => {
                Category SelectedCategory = Category.Find(parameters.id);
                return(View["category_delete.cshtml", SelectedCategory]);
            };
            Post["category/delete/{id}"] = parameters => {
                Category SelectedCategory = Category.Find(parameters.id);
                SelectedCategory.Delete();
                return(View["success.cshtml"]);
            };
        }
Esempio n. 19
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"]);
            };
            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]);
            };
        }