public IActionResult Edit(string name, string list) { if (ModelState.IsValid) { ViewBag.Key = _currentList; var item = _AllLists.FirstOrDefault(a => a.Name == _currentList); var list_exist = _AllLists.Find(a => a.Name == name); if (list_exist == null) { if (name != null) { item.Name = name; if (item._ToDoList != null) { foreach (var t in item._ToDoList) { t.TaskListId = list; _client.PutToDoTaskAsync(t.ToDoTaskId, t); } } return(RedirectToAction(nameof(Index))); } } else { ModelState.AddModelError("", "List with this Name exist! Change Name."); return(View()); } } ModelState.AddModelError("", "Wrong data!!!"); return(View()); }
public async Task <IActionResult> EditTaskAsync(int id, ToDoTask task, string listid) { task.TaskListId = listid; task.CreateDate = DateTime.Now.ToString(); ToDoTasksClient tasksClient = new ToDoTasksClient(); await tasksClient.PutToDoTaskAsync(id, task); return(RedirectToAction("Tasks", "TaskLists", new { list = listid })); }
//Метод який завершує задачу і виконує софт видалення //Задача пропадає з користувацьких списків public async Task <IActionResult> Complet(int id) { ToDoTasksClient tasksClient = new ToDoTasksClient(); var tasks = await tasksClient.GetTasks2Async(id); tasks.IsDeleted = true; tasks.Isactive = true; await tasksClient.PutToDoTaskAsync(id, tasks); return(RedirectToAction("Tasks", "TaskLists", new { list = tasks.TaskListId })); }
public async Task <IActionResult> Edit(string name, string key) { var item = TaskLists.FirstOrDefault(a => a.Key == key); var val = item.Value; List <ToDoTask> newList = new List <ToDoTask>(); ToDoTasksClient tasksClient = new ToDoTasksClient(); foreach (var t in val) { t.TaskListId = name; newList.Add(t); await tasksClient.PutToDoTaskAsync(t.ToDoTaskId, t); } TaskLists.Remove(item.Key); TaskLists.Add(name, newList); return(RedirectToAction(nameof(Index))); }