public async Task ToggleTask(Guid id) { var taskVm = Tasks.FirstOrDefault(x => x.Id == id); if (taskVm == null) { throw new ArgumentNullException("Task was not choosen."); } var result = await Complete(taskVm.ToCompleteTaskCommand()); if (result != null && result.Succees) { foreach (var taskModel in Tasks) { if (taskModel.Id == id) { taskModel.IsComplete = true; } } TasksUpdated?.Invoke(this, null); } else { CompleteTaskFailed.Invoke(this, "Unable to complete task."); } }
public async Task ToggleTask(Guid id) { var taskVm = _tasks.SingleOrDefault(task => task.Id == id); var result = await Complete(taskVm.ToCompleteTaskCommand()); if (result?.Succeed ?? false) { taskVm.IsComplete = true; TasksUpdated?.Invoke(this, null); } else { CompleteTaskFailed.Invoke(this, "Unable to complete task."); } }
public async void CompleteTask(Guid id) { var result = await CompleteTask(new CompleteTaskCommand() { TaskId = id }); if (result.Succeed) { var updatedList = (await GetAllTasks()).Payload; tasks = updatedList; TasksChanged?.Invoke(this, null); } else { CompleteTaskFailed?.Invoke(this, "Unable to complete task."); } }
public async Task ToggleTask(Guid id) { var taskViewModel = Tasks.Where(t => t.Id == id).FirstOrDefault(); if (taskViewModel == null) { throw new ArgumentNullException("Task was not chosen."); } var result = await Complete(taskViewModel.ToCompleteTaskCommand()); if (result != null && result.Succeed) { taskViewModel.IsComplete = true; TasksUpdated?.Invoke(this, null); } else { CompleteTaskFailed.Invoke(this, "Unable to complete task."); } }