private void IdentifyError(Bet bet, JToken errors) { foreach (var error in errors) { var arguments = (JArray)error["arguments"]; switch (error["type"].Val()) { case "VET_STAKE_TOO_LOW": bet.AddError(BetError.StakeTooLow); bet.MinStake = arguments.Count() > 0 ? (double?)arguments[0] / 1000 : 0; return; case "VET_ODDS_CHANGED": bet.AddError(BetError.PriceChanged); var newOdds = arguments.Count() > 0 ? (int)arguments[0] : 0; UpdateOdds(bet, newOdds); return; case "VET_BET_OFFER_CLOSED": bet.AddError(BetError.Ended); return; default: CurrentBetslip.Status = BetslipStatus.UnknownError; return; } } }
/* Проверяем результат валидации coupon-а на ошибки * "betErrors": [ * {"betIndex": 0, * "errors": [{"type": "VET_INVALID_BET"}] * }], * "outcomeErrors": [ * {"outcomeId": 2699153202, * "outcomeIds": [2699153202], * "errors": [ * {"type": "VET_ODDS_CHANGED", * "arguments": ["6000"]} * ]}]*/ protected void ManageValidateResult(Bet bet, JToken responseCheckCoupon) { using (Logger.BeginScope(LoggerHelper.GetCaller())) { var outcomeErrors = responseCheckCoupon["outcomeErrors"]; if (outcomeErrors != null) { for (var i = 0; i < outcomeErrors.Count(); i++) { var id = (long)outcomeErrors[i]["outcomeId"]; var betError = CurrentBetslip.GetSelectionByKey(id); IdentifyError(betError, outcomeErrors[i]["errors"]); } } if (bet.BetType.Code != BetTypeCode.Single) { bet.AddError(BetError.Unexpected); } CheckSameEvent(responseCheckCoupon["requestCoupon"]?["outcomeIds"]); } }