コード例 #1
0
        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));
        }
コード例 #2
0
        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));
        }