private void Apply(UserJoinedGameEvent @event) { _users.Add(@event.UserId); }
public Game AddUser(Guid userId) { if (_users.Any(id => userId == id)) { throw new InvalidOperationException("User is already in game."); } if (IsFull()) { throw new InvalidOperationException("Game is full."); } var userJoinedEvent = new UserJoinedGameEvent(Guid.NewGuid(), Id, userId, Version + 1); RaiseEvent(userJoinedEvent); return this; }