private async Task NewSubTaskAsync() { string subTaskTitle = await _dialogService.ShowInputStringDialogAsync( "Type the sub task title", string.Empty, "Save", "Cancel"); if (string.IsNullOrEmpty(subTaskTitle)) { return; } if (CurrentTask.SubTasks == null) { CurrentTask.SubTasks = new SmartObservableCollection <TaskItemViewModel>(); } CurrentTask.SubTasks.Add(new TaskItemViewModel { Title = subTaskTitle, UpdatedAt = DateTimeOffset.UtcNow, Status = GoogleTaskStatus.NEEDS_ACTION.GetString() }); if (!CurrentTask.HasSubTasks) { CurrentTask.HasSubTasks = true; } }
public async Task UpdateTaskListAsync(TaskListItemViewModel taskList) { int index = TaskLists.IndexOf(taskList); string newTitle = await _dialogService.ShowInputStringDialogAsync( "Type the new task list name", taskList.Title, "Update", "Cancel"); if (string.IsNullOrEmpty(newTitle)) { return; } _messenger.Send(true, $"{MessageType.SHOW_CONTENT_FRAME_PROGRESS_RING}"); var dbResponse = await _dataService .TaskListService .FirstOrDefaultAsNoTrackingAsync(t => t.GoogleTaskListID == taskList.TaskListID); if (!dbResponse.Succeed) { await _dialogService.ShowMessageDialogAsync( "Error", $"An unknown error occurred while trying to retrieve the task list from db. Error = {dbResponse.Message}"); return; } dbResponse.Result.Title = newTitle; dbResponse.Result.UpdatedAt = DateTimeOffset.UtcNow; dbResponse.Result.ToBeSynced = true; if (dbResponse.Result.LocalStatus != LocalStatus.CREATED) { dbResponse.Result.LocalStatus = LocalStatus.UPDATED; } var response = await _dataService .TaskListService .UpdateAsync(dbResponse.Result); if (!response.Succeed) { _messenger.Send(false, $"{MessageType.SHOW_CONTENT_FRAME_PROGRESS_RING}"); await _dialogService.ShowMessageDialogAsync( "Error", $"Coudln't update the task list {taskList.Title}. Error = {response.Message}"); return; } TaskLists[index] = _mapper.Map <TaskListItemViewModel>(dbResponse.Result); _messenger.Send(false, $"{MessageType.SHOW_CONTENT_FRAME_PROGRESS_RING}"); //If the updated task is the same as the selected one //we update SelectedItem if (SelectedItem == taskList) { SelectedItem = TaskLists[index]; } }