public async Task <Board> DeleteBoardAsync(Board board) { if (!await boardRepository.CheckBoardExistsAsync(board.Id)) { throw new ArgumentException("Board with specified Id does not exist"); } this.context.Boards.Remove(board); await this.context.SaveChangesAsync(); return(board); }
public async Task <List <Todo> > GetAllTodosOfBoardAsync(string boardId) { if (!await boardRepository.CheckBoardExistsAsync(boardId)) { throw new ArgumentException("Board with specified Id does not exist"); } return(await context.Todos.Where(t => t.BoardId == boardId).ToListAsync()); }
public async Task <Todo> AddTodoAsync(Todo todo) { if (!await boardRepository.CheckBoardExistsAsync(todo.BoardId)) { throw new ArgumentException("Board with specified Id does not exist"); } todo.Id = null; todo.CreationDate = DateTime.Now; context.Todos.Add(todo); await context.SaveChangesAsync(); context.Detach(todo); return(todo); }
public async Task <BoardInfoResult> Handle(BoardInfoQuery request, CancellationToken cancellationToken) { if (string.IsNullOrWhiteSpace(request.BoardId)) { throw new ArgumentException("BoardId cannot be null or white space"); } if (!await boardRepository.CheckBoardExistsAsync(request.BoardId)) { return(new BoardInfoResult { Result = null }); } var result = await boardRepository.GetBoardInfoByIdAsync(request.BoardId); return(new BoardInfoResult { Result = result }); }