private async void ValidateBonus(OfflineWithdraw withdrawal, Payment.Data.Player player) { if (!_configuration.HasBonusCheck) { return; } var latestDeposit = _paymentRepository.OfflineDeposits .Where(o => o.Status == OfflineDepositStatus.Approved && o.PlayerId == player.Id) .OrderByDescending(o => o.Approved.Value) .First(); var allowedBonuses = _configuration.AllowedBonuses.Select(o => o.Name); var bonusName = latestDeposit.BonusRedemptionId.HasValue ? (await _bonusApiProxy.GetBonusRedemptionAsync(latestDeposit.PlayerId, latestDeposit.BonusRedemptionId.Value)).Bonus.Name : string.Empty; var isSuccess = !string.IsNullOrEmpty(bonusName) && allowedBonuses.Contains(bonusName); var metadataForRule = GenerateFullRuleDescriptionAndValue( VerificationStep.RecentBonus, ComparisonEnum.Of, string.Join(",", allowedBonuses.ToArray()), bonusName); OnRuleFinish(isSuccess, withdrawal.Id, VerificationStep.RecentBonus, metadataForRule); }
public async Task <PlayerLastDepositSummaryResponse> PlayerLastDepositSummaryResponse([FromUri] PlayerLastDepositSummary request) { var playerLastDepositSummaryResponse = new PlayerLastDepositSummaryResponse(); var deposits = _onlineDepositQueries.GetOnlineDepositsByPlayerId(PlayerId); if (deposits == null) { throw new RegoException(ErrorMessagesEnum.ServiceUnavailable.ToString()); } var lastDeposit = deposits.OrderByDescending(x => x.DateApproved).First(); if (lastDeposit == null) { throw new RegoException("Can't find deposit"); } playerLastDepositSummaryResponse.Amount = lastDeposit.Amount; if (lastDeposit.BonusRedemptionId.HasValue) { var redemption = await _bonusApiProxy.GetBonusRedemptionAsync(PlayerId, lastDeposit.BonusRedemptionId.Value); if (redemption == null) { throw new RegoException(ErrorMessagesEnum.ServiceUnavailable.ToString()); } playerLastDepositSummaryResponse.BonusAmount = redemption.Amount; playerLastDepositSummaryResponse.BonusCode = lastDeposit.BonusCode; } return(playerLastDepositSummaryResponse); }
public async Task <Bonus.Core.Models.Data.BonusRedemption> GetRedemption(Guid redemptionId) { var redemption = await _bonusApiProxy.GetBonusRedemptionAsync(PlayerId, redemptionId); if (redemption == null) { throw new RegoValidationException(ErrorMessagesEnum.RedemptionWithSuchIdDoesntExist.ToString()); } return(redemption); }
public async Task <ActionResult> GetForView(Guid id) { var response = GetAdminApiProxy(Request).GetOfflineDepositById(id); var offlineDeposit = response.OfflineDeposit; var viewModel = new OfflineDepositViewModel(offlineDeposit); if (offlineDeposit.BonusRedemptionId.HasValue) { var player = _playerQueries.GetPlayer(offlineDeposit.PlayerId); if (!_adminQueries.IsBrandAllowed(CurrentUser.Id, player.BrandId)) { throw new HttpException(403, "Access forbidden"); } var redemption = await _bonusApiProxy.GetBonusRedemptionAsync(offlineDeposit.PlayerId, offlineDeposit.BonusRedemptionId.Value); viewModel.BonusName = redemption.Bonus.Name; } return(this.Success(viewModel)); }
public async Task <Interface.Bonus.BonusRedemptionResponse> Get(Guid playerId, Guid redemptionId) { var player = _playerQueries.GetPlayer(playerId); CheckBrand(player.BrandId); var redemptionTask = _bonusApiProxy.GetBonusRedemptionAsync(playerId, redemptionId); var licenseeName = _brandQueries.GetLicensee(player.Brand.LicenseeId).Name; var redemption = await redemptionTask; return(new Interface.Bonus.BonusRedemptionResponse { LicenseeName = licenseeName, BrandName = player.Brand.Name, Username = player.Username, BonusName = redemption.Bonus.Name, ActivationState = redemption.ActivationState.ToString(), RolloverState = redemption.RolloverState.ToString(), Amount = redemption.Amount.Format(), LockedAmount = redemption.LockedAmount.Format(), Rollover = redemption.Rollover.Format() }); }