/// <summary> /// Registers a Win bet action /// </summary> /// <param name="gameActionData"></param> /// <param name="context"></param> /// <returns></returns> async Task <Guid> IGameCommands.WinBetAsync([NotNull] GameActionData gameActionData, [NotNull] GameActionContext context) { var gameProviderId = await ValidateGameProvider(context.GameProviderCode); ValidateTransactionIsUnique(gameActionData.ExternalTransactionId, gameProviderId); using (var scope = CustomTransactionScope.GetTransactionScopeAsync()) { var round = GetRound(gameActionData); await _walletOperations.WinBetAsync(round.Data.PlayerId, round.Data.GameId, round.Data.Id, gameActionData.Amount, gameActionData.ExternalTransactionId); var winGameActionId = round.Win(gameActionData, context); await _repository.SaveChangesAsync(); round.Events.ForEach(ev => _eventBus.Publish(ev)); scope.Complete(); return(winGameActionId); } }
async Task <Guid> IGameCommands.WinBetAsync([NotNull] GameActionData actionData, [NotNull] GameActionContext context) { var gameProviderId = await ValidateGameProviderAsync(context.GameProviderCode); ValidateTransactionIsUnique(actionData.ExternalTransactionId, gameProviderId); using (var scope = CustomTransactionScope.GetTransactionScopeAsync()) { var round = GetRound(actionData); var walletTransactionId = await _walletOperations.WinBetAsync(round.Data.PlayerId, round.Data.GameId, round.Data.Id, actionData.Amount); var winGameActionId = round.Win( actionData.Amount, actionData.Description, walletTransactionId, actionData.ExternalTransactionId, actionData.ExternalBetId, actionData.TransactionReferenceId, actionData.BatchId); await _repository.SaveChangesAsync(); await _gameEventsProcessor.Process(round.Events, context.PlayerToken, round.Data.BrandCode, actionData, context.GameProviderCode); scope.Complete(); return(winGameActionId); } }