public async Task <Board> AddBoardAsync(Board board) { board.Id = null; board.CreationDate = DateTime.Now; this.context.Boards.Add(board); await this.context.SaveChangesAsync(); context.Detach(board); return(board); }
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); }