/// <summary> /// Adds an <see cref="Exemption"/> and it's optional attributes to this collection. /// </summary> /// <param name="value">A string pattern that should be exempt.</param> /// <param name="attributes">A set of attributes that applies to this exemption.</param> public void Add(string value, AttributeCollection attributes = null) { var exemption = new Exemption(value); if (_exemptions.TryGetValue(exemption, out var existingAttributes)) { if (existingAttributes != null) { if (attributes != null) { existingAttributes.Merge(attributes); } else { _exemptions[exemption] = null; } } else { _exemptions[exemption] = attributes; } } else { _exemptions.Add(exemption, attributes); } }
public void SaveExemption(Exemption exemption) { using (var scope = CustomTransactionScope.GetTransactionScope()) { var player = _repository.Players.Single(x => x.Id == exemption.PlayerId); var brand = _brandQueries.GetBrandOrNull(player.BrandId); var exemptFrom = DateTime.Parse(exemption.ExemptFrom, CultureInfo.InvariantCulture); var exemptTo = DateTime.Parse(exemption.ExemptTo, CultureInfo.InvariantCulture); if (exemptTo < exemptFrom) { throw new ArgumentException("ExemptTo must be greater or equal then ExemptFrom."); } player.ExemptWithdrawalVerification = exemption.Exempt; player.ExemptWithdrawalFrom = exemptFrom.ToBrandDateTimeOffset(brand.TimezoneId); player.ExemptWithdrawalTo = exemptTo.ToBrandDateTimeOffset(brand.TimezoneId); player.ExemptLimit = exemption.ExemptLimit; _repository.SaveChanges(); _eventBus.Publish(new PlayerAccountRestrictionsChanged( player.Id, player.ExemptLimit, player.ExemptWithdrawalTo, player.ExemptWithdrawalFrom, player.ExemptWithdrawalVerification) { EventCreated = DateTimeOffset.Now.ToBrandOffset(brand.TimezoneId), }); scope.Complete(); } }
public IHttpActionResult SubmitExemption(Exemption exemption) { VerifyPermission(Permissions.Exempt, Modules.OfflineWithdrawalExemption); if (!ModelState.IsValid) { return(Ok(ErrorResponse())); } _withdrawalService.SaveExemption(exemption); return(Ok(new { Result = "success" })); }
public void Cannot_save_exemption_offline_withdraw_with_invalid_brand() { // Arrange var playerBankAccount = CreateNewPlayerBankAccount(DefaultBrandId); var exemption = new Exemption { PlayerId = playerBankAccount.Player.Id, Exempt = true, ExemptFrom = DateTime.Now.ToString(CultureInfo.InvariantCulture), ExemptTo = DateTime.Now.ToString(CultureInfo.InvariantCulture), ExemptLimit = 1 }; LogWithNewAdmin(Modules.OfflineWithdrawalExemption, Permissions.Exempt); // Act Assert.Throws <InsufficientPermissionsException>(() => _withdrawalService.SaveExemption(exemption)); }
public void ThenExemptionIsSuccessfullySubmitted() { ScenarioContext.Current.Should().ContainKey("playerId"); var playerId = ScenarioContext.Current.Get <Guid>("playerId"); var exemption = new Exemption { PlayerId = playerId, Exempt = true, ExemptFrom = DateTime.Now.ToString(CultureInfo.InvariantCulture), ExemptTo = DateTime.Now.ToString(CultureInfo.InvariantCulture), ExemptLimit = 1 }; var result = AdminApiProxy.SubmitExemptionInPlayerInfo(exemption); result.Should().NotBeNull(); result.StatusCode.ShouldBeEquivalentTo(HttpStatusCode.OK); }
public ActionResult Exemption(int onlineExemptionID) { var exemption = new Exemption(MasterExemption_DTO.GetMasterExemption_For(onlineExemptionID), AdministrativeProperties_DTO.Get(onlineExemptionID)); return View(exemption); }
public void Withdrawal_goes_directly_to_acceptance_queue_after_exemption_applied() { var brandId = _brandQueries.GetBrands().First().Id; var licenseeId = _brandQueries.GetBrands().First().Licensee.Id; var currency = _brandQueries.GetBrands().First().DefaultCurrency; var vipLevelId = (Guid)_brandQueries.GetBrands().First().DefaultVipLevelId; var playerId = new Guid(); var playersAffectedByAvc = _playerQueries.GetPlayers() .Where(player => player.BrandId == brandId && player.Brand.LicenseeId == licenseeId && player.CurrencyCode == currency && player.VipLevelId == vipLevelId); if (playersAffectedByAvc.Any()) { playerId = playersAffectedByAvc.FirstOrDefault().Id; } //Create a new avc that has a withdrawal exemption CreateAvcConfiguration(new AVCConfigurationDTO { Licensee = licenseeId, Brand = brandId, Currency = currency, VipLevels = new[] { vipLevelId }, HasWithdrawalExemption = true, HasWithdrawalCount = true, TotalWithdrawalCountAmount = 85, TotalWithdrawalCountOperator = ComparisonEnum.Greater, Status = AutoVerificationCheckStatus.Active }); _paymentTestHelper.MakeDeposit(playerId, 1000); Balance.Main = 1000; //Setup an exemption for a particular player that will make a withdrawal request later in the test case. var playerExemption = new Exemption { Exempt = true, ExemptFrom = DateTime.UtcNow.AddDays(-2).ToString(CultureInfo.InvariantCulture), ExemptTo = DateTime.UtcNow.AddDays(2).ToString(CultureInfo.InvariantCulture), ExemptLimit = 1, PlayerId = playerId }; _withdrawalService.SaveExemption(playerExemption); //Create the offline withdrawal request MakeWithdrawalRequest(playerId, playersAffectedByAvc); var numberOfVerifiedWithdrawals = _withdrawalService .GetWithdrawalsVerified().Count(wd => wd.PlayerBankAccount.Player.Id == playerId); Assert.AreEqual(1, numberOfVerifiedWithdrawals); //Since we are allowed to only one exemption, this means that on the next withdrawal //we must have our withdrawal request in the verification queue but not in the acceptance queue MakeWithdrawalRequest(playerId, playersAffectedByAvc); Assert.AreEqual(1, numberOfVerifiedWithdrawals); }
public HttpResponseMessage SubmitExemptionInPlayerInfo(Exemption request) { return(WebClient.SecurePostAsJson <Exemption, HttpResponseMessage>(Token, _url + AdminApiRoutes.SubmitExemptionInPlayerInfo, request)); }