public async Task <AssetPairContract> Insert([FromBody] AssetPairContract assetPair)
        {
            await ValidatePairInsert(assetPair);

            _defaultLegalEntitySettings.Set(assetPair);

            var inserted = await _assetPairsRepository.InsertAsync(
                _convertService.Convert <AssetPairContract, AssetPair>(assetPair));

            if (inserted == null)
            {
                throw new ArgumentException($"Asset pair with id {assetPair.Id} already exists", nameof(assetPair.Id));
            }

            var insertedContract = _convertService.Convert <IAssetPair, AssetPairContract>(inserted);

            await _eventSender.SendSettingsChangedEvent($"{Request.Path}", SettingsChangedSourceType.AssetPair,
                                                        inserted.Id);

            await _cqrsMessageSender.SendAssetPairChangedEvent(new AssetPairChangedEvent
            {
                OperationId = Guid.NewGuid().ToString("N"),
                AssetPair   = insertedContract,
            });

            return(insertedContract);
        }
예제 #2
0
 public async Task<IAssetPair> InsertAssetPair(IAssetPair assetPair)
 {
     ValidatePair(assetPair);
     await _assetPairsRepository.InsertAsync(assetPair);
     InitAssetPairs();
     return _assetPairsCache.GetAssetPairByIdOrDefault(assetPair.Id)
         .RequiredNotNull("AssetPair " + assetPair.Id);
 }