//Виводимо розумний список задач public async Task <IActionResult> SmartTasks(string smart, string hide = "show") { ViewData["HideComolet"] = hide == "hide" ? "show" : "hide"; ViewData["SmartName"] = smart; ToDoTasksClient tasksClient = new ToDoTasksClient(); var tasks = await tasksClient.GetTasksAsync(smart, hide); return(View(tasks.ToList())); }
//Отримуємо один раз всі задачі і формуємо списки public async Task <IActionResult> Index() { if (first) { var tasks = await _client.GetTasksAsync(); ToDoList toDoList = new ToDoList(); if (tasks.Count != 0) { var sort_tasks = tasks.OrderBy(a => a.TaskListId); string _listName = sort_tasks.First().TaskListId; foreach (var item in sort_tasks) { if (item.Isactive != true) { if (_listName == item.TaskListId) { toDoList.Name = _listName; toDoList._ToDoList.Add(item); } else { toDoList.Name = _listName; _AllLists.Add(toDoList); toDoList = new ToDoList(); _listName = item.TaskListId; toDoList.Name = _listName; toDoList._ToDoList.Add(item); } } all_tasks._ToDoList.Add(item); if (item.Date != null) { planned_tasks._ToDoList.Add(item); } if (item.Taskimportance.ToString() == "High") { important_tasks._ToDoList.Add(item); } if (item.Date == DateTime.Now.Date) { today_tasks._ToDoList.Add(item); } } _AllLists.Add(toDoList); } first = false; } return(View(_AllLists)); }
//Користувацькі списки //Метод формує список користувача public async Task <IActionResult> Tasks(string list, string sort) { ViewData["list"] = list; ViewData["title"] = sort == "title" ? "title_desc" : "title"; ViewData["description"] = sort == "description" ? "description_desc" : "description"; ViewData["taskimportance"] = sort == "taskimportance" ? "taskimportance_desc" : "taskimportance"; ViewData["date"] = sort == "date" ? "date_desc" : "date"; ViewData["isactive"] = sort == "isactive" ? "isactive_desc" : "isactive"; ViewData["CreateDate"] = sort == "CreateDate" ? "CreateDate_desc" : "CreateDate"; ToDoTasksClient tasksClient = new ToDoTasksClient(); var tasks = await tasksClient.GetTasksAsync("custom", list); var task = SortOrder(sort, tasks.ToList()); return(View(task)); }
public async Task <IActionResult> DeleteTask(int id, string listid) { ToDoTasksClient tasksClient = new ToDoTasksClient(); //Організовуємо видалення мульти задач var tasks = await tasksClient.GetTasksAsync("custom", listid); var item = tasks.FirstOrDefault(a => a.ToDoTaskId == id); foreach (var t in tasks) { if ((t.IsMultipleTask == true && t.Title == item.Title) || item == t) { await tasksClient.DeleteToDoTaskAsync(t.ToDoTaskId); } } return(RedirectToAction("Tasks", "TaskLists", new { list = listid })); }
public async Task <IActionResult> Search(string sort, string title_search) { ViewData["CurrentFilter"] = title_search; if (!String.IsNullOrEmpty(title_search)) { ViewData["title"] = sort == "title" ? "title_desc" : "title"; ViewData["description"] = sort == "description" ? "description_desc" : "description"; ViewData["taskimportance"] = sort == "taskimportance" ? "taskimportance_desc" : "taskimportance"; ViewData["date"] = sort == "date" ? "date_desc" : "date"; ViewData["isactive"] = sort == "isactive" ? "isactive_desc" : "isactive"; ViewData["CreateDate"] = sort == "CreateDate" ? "CreateDate_desc" : "CreateDate"; ToDoTasksClient tasksClient = new ToDoTasksClient(); var search_task = await tasksClient.GetTasksAsync("search", title_search); search_task = SortOrder(sort, search_task.ToList()); return(View(search_task.ToList())); } return(RedirectToAction(nameof(Index))); }