public async Task HandleAsync(ChangeBookValueCommand command) { var currency = command.Currency ?? throw new BrokenBusinessRuleException(new RequiredValueException(nameof(command.Stake))); var bookType = command.BookType ?? throw new BrokenBusinessRuleException(new RequiredValueException(nameof(command.BookType))); var bookMatch = await _bookMatchRepository.FindByUserAndMatchIdsAsync(command.UserId, command.MatchId); if (bookMatch == null) { throw new BrokenBusinessRuleException(new DoesNotExistException()); } bookMatch.ChangeBookValue(command.Stake, currency, bookType.ToEnum(BookType.Draw)); }
public async Task HandleAsync(CloseBookmakingCommand command) { var bookMatch = await _bookMatchRepository.FindByUserAndMatchIdsAsync(command.UserId, command.MatchId); if (bookMatch == null) { throw new BrokenBusinessRuleException(new DoesNotExistException()); } bookMatch.Close(); //TODO: Add Outbox pattern await _busPublisher.PublishEventAsync( new CloseBookmakingEvent( Guid.NewGuid(), SystemTime.Now(), command.MatchId, command.UserId)); }