private PurchaseErrorCode ValidatePurchaseRequest(CustomerKey customerKey, Money totalCost) { VirtualAccount account = _virtualAccountServiceGateway.GetAccount(customerKey); if (account.Balance.AvailableAmount < totalCost) { return(PurchaseErrorCode.NotEnoughFunds); } BetLimitStatusAfterBet betPeriodSummary = _bettingServiceGateway.GetBetLimitStatusForAmount(customerKey, totalCost); if (betPeriodSummary.AffectedLimit == BetLimit.LimitNotSet) { return(PurchaseErrorCode.LimitNotSet); } if (betPeriodSummary.Exceeded) { switch (betPeriodSummary.AffectedLimit) { case BetLimit.Daily: return(PurchaseErrorCode.ExceededDailyBetLimit); case BetLimit.Weekly: return(PurchaseErrorCode.ExceededWeeklyBetLimit); case BetLimit.Monthly: return(PurchaseErrorCode.ExceededMonthlyBetLimit); default: return(PurchaseErrorCode.ExceededDailyBetLimit); } } return(PurchaseErrorCode.NotSet); }
public IHttpActionResult GetCredit() { CustomerKey customerKey = _customerProvider.FindCurrentCustomerKey(); BetLimitStatusAfterBet betLimitStatus = _bettingServiceGateway.GetBetLimitStatusForAmount(customerKey, Money.FromKroner(0)); VirtualAccount account = _virtualAccountServiceGateway.GetAccount(customerKey); var model = new Credit { Balance = account.Balance.AvailableAmount.Amount, RemainingBetLimit = betLimitStatus.LowestLimitRemainder.Amount, HasBetLimit = betLimitStatus.AffectedLimit != BetLimit.LimitNotSet }; return(Ok(RestResult <Credit> .CreateSuccess(model))); }