Пример #1
0
        public IActionResult DeleteConfirmed(string key)
        {
            var item = _AllLists.FirstOrDefault(a => a.Name == key);

            if (item._ToDoList != null)
            {
                foreach (var t in item._ToDoList)
                {
                    _client.DeleteToDoTaskAsync(t.ToDoTaskId);
                    all_tasks._ToDoList.Remove(t);
                    planned_tasks._ToDoList.Remove(t);
                    important_tasks._ToDoList.Remove(t);
                    today_tasks._ToDoList.Remove(t);
                }
            }
            _AllLists.Remove(item);
            return(RedirectToAction(nameof(Index)));
        }
        public async Task <IActionResult> DeleteConfirmed(string key)
        {
            ToDoTasksClient client = new ToDoTasksClient();
            var             item   = TaskLists.FirstOrDefault(a => a.Key == key);

            if (item.Value != null)
            {
                foreach (var t in item.Value)
                {
                    await client.DeleteToDoTaskAsync(t.ToDoTaskId, key);
                }
            }
            TaskLists.Remove(key);
            return(RedirectToAction(nameof(Index)));
        }
        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 }));
        }