public async Task <List <TradingConditionContract> > List([FromQuery] bool?isDefault = null) { var data = isDefault.HasValue ? await _tradingConditionsService.GetByDefaultFilterAsync(isDefault.Value): await _tradingConditionsService.GetAsync(); return(data .Select(x => _convertService.Convert <ITradingCondition, TradingConditionContract>(x)).ToList()); }
private async Task ValidateRoute(MatchingEngineRouteContract route) { if (route == null) { throw new ArgumentNullException(nameof(route), "Model is incorrect"); } if (string.IsNullOrWhiteSpace(route?.Id)) { throw new ArgumentNullException(nameof(route.Id), "Route Id must be set"); } if (route.Type != null && !Enum.IsDefined(typeof(OrderDirectionContract), route.Type)) { throw new ArgumentNullException(nameof(route.Type), "Route Type is set to an incorrect value"); } if (!string.IsNullOrEmpty(route.TradingConditionId) && await _tradingConditionsService.GetAsync(route.TradingConditionId) == null) { throw new InvalidOperationException($"Trading condition {route.TradingConditionId} does not exist"); } if (!string.IsNullOrEmpty(route.Instrument) && await _assetPairsService.GetByIdAsync(route.Instrument) == null) { throw new InvalidOperationException($"Asset pair {route.Instrument} does not exist"); } if (string.IsNullOrEmpty(route.Asset) || route.Asset == AnyValue) { route.Asset = AnyValue; } else if (await _assetsRepository.GetAsync(route.Asset) == null) { throw new InvalidOperationException($"Asset {route.Asset} does not exist"); } }