public async Task <TaskList> Handle(GetTaskListDetailsByIdQuery request, CancellationToken cancellationToken) { if (request == null) { throw new ArgumentNullException(nameof(request)); } var taskListResult = await taskListGetter.GetByIdAsync(request.Id, cancellationToken); if (taskListResult == null) { throw new ArgumentNullException(nameof(taskListResult)); } var taskCards = await taskCardGetter.GetAllByTaskListIdAsync(taskListResult.Id, cancellationToken); var taskList = new TaskList( id: taskListResult.Id, boardId: taskListResult.BoardId, title: taskListResult.Title, description: taskListResult.Description, cards: taskCards ); return(taskList); }
public async Task <bool> Handle(DeleteTaskCardCommand request, CancellationToken cancellationToken) { if (request == null) { throw new ArgumentNullException(nameof(request)); } bool result = false; // First: Get the card that should be deleted so that you can have the list id var getTaskCardDeleted = await getTaskCard.GetByIdAsync(request.Id, cancellationToken).ConfigureAwait(false); // Second: delete the card var taskCardDeleteResult = await deleteTaskCard.DeleteAsync(request.Id, cancellationToken).ConfigureAwait(false); if (taskCardDeleteResult) { // Third: Get the remaining cards in the column var getTaskCardList = await getTaskCard.GetAllByTaskListIdAsync(getTaskCardDeleted.ListId, cancellationToken).ConfigureAwait(false); //Forth: Update the cards positioning result = await updateTaskCard.UpdateTaskCardsPositionAsync(getTaskCardList.ToList(), cancellationToken).ConfigureAwait(false); } return(result); }
public async Task <TaskBoard> Handle(GetTaskBoardDetailsByIdQuery request, CancellationToken cancellationToken) { if (request == null) { throw new ArgumentNullException(nameof(request)); } var boardResult = await taskBoardGetter.GetByIdAsync(request.Id, cancellationToken).ConfigureAwait(false); if (boardResult == null) { throw new ArgumentNullException(nameof(boardResult)); } var columnsResult = await taskListGetter.GetAllByTaskBoardIdAsync(boardResult.Id, cancellationToken); var taskLists = new List <TaskList>(); foreach (var column in columnsResult) { if (column == null) { throw new ArgumentNullException(nameof(column)); } var orderedTaskCards = new List <TaskCard>(); orderedTaskCards.AddRange((await taskCardGetter.GetAllByTaskListIdAsync(column.Id, cancellationToken)).OrderBy(opts => opts.Position)); taskLists.Add( new TaskList( id: column.Id, boardId: column.BoardId, title: column.Title, description: column.Description, cards: orderedTaskCards ) ); } var taskBoard = new TaskBoard( id: boardResult.Id, userId: boardResult.UserId, title: boardResult.Title, description: boardResult.Description, lists: taskLists ); return(taskBoard); }
public async Task <IEnumerable <TaskCard> > Handle(GetAllTaskCardsByListIdQuery request, CancellationToken cancellationToken) { var result = await taskCardGetter.GetAllByTaskListIdAsync(request.ListId, cancellationToken); return(result); }