public async Task <IActionResult> Update([FromBody] UpdateVolatilitySettingsModel model) { try { IVolatilitySettings updatedSettings = await _volatilitySettingsService.UpdateAsync( new VolatilitySettings { MerchantId = model.MerchantId, ZeroCoverageAssetPairs = model.ZeroCoverageAssetPairs, IsDeltaSpreadFixed = model.IsDeltaSpreadFixed }); if (updatedSettings == null) { return(NotFound(ErrorResponse.Create("Merchant volatility settings not found"))); } return(Ok()); } catch (VolatilitySettingsEmptyException e) { _log.Error(e, "Asset pairs value is empty"); return(BadRequest(ErrorResponse.Create(e.Message))); } }
public async Task <IVolatilitySettings> AddAsync(IVolatilitySettings src) { var entity = VolatilitySettingsEntity.ByMerchant.Create(src); await _storage.InsertThrowConflict(entity); return(Mapper.Map <VolatilitySettings>(entity)); }
public async Task <IActionResult> Get([Required, RowKey] string merchantId) { IVolatilitySettings settings = await _volatilitySettingsService.GetAsync(merchantId); if (settings == null) { return(NotFound(ErrorResponse.Create("Merchant volatility settings not found"))); } return(Ok(new VolatilitySettingsResponse { MerchantId = settings.MerchantId, ZeroCoverageAssetPairs = settings.ZeroCoverageAssetPairs, IsDeltaSpreadFixed = settings.IsDeltaSpreadFixed })); }
public async Task <IVolatilitySettings> AddAsync(IVolatilitySettings src) { try { IVolatilitySettings newSettings = await _repository.AddAsync(src); _log.Info("Merchant volatility settings added", newSettings.ToDetails()); return(newSettings); } catch (DuplicateKeyException e) { _log.Error(e, context: src.ToDetails()); throw new VolatilitySettingsAlreadyExistException(src.MerchantId); } }
public async Task <IVolatilitySettings> UpdateAsync(IVolatilitySettings src) { try { if (string.IsNullOrEmpty(src.ZeroCoverageAssetPairs)) { throw new VolatilitySettingsEmptyException(src.MerchantId); } IVolatilitySettings updatedSettings = await _repository.UpdateAsync(src); _log.Info("Merchant volatility settings have been updated", updatedSettings.ToDetails()); return(updatedSettings); } catch (KeyNotFoundException e) { _log.Warning("Merchant volatility settings not found", e); return(null); } }
public async Task <IVolatilitySettings> UpdateAsync(IVolatilitySettings src) { VolatilitySettingsEntity updatedEntity = await _storage.MergeAsync( VolatilitySettingsEntity.ByMerchant.GeneratePartitionKey(src.MerchantId), VolatilitySettingsEntity.ByMerchant.GenerateRowKey(src.MerchantId), entity => { if (!string.IsNullOrEmpty(src.ZeroCoverageAssetPairs)) { entity.ZeroCoverageAssetPairs = src.ZeroCoverageAssetPairs; } entity.IsDeltaSpreadFixed = src.IsDeltaSpreadFixed; return(entity); }); if (updatedEntity == null) { throw new KeyNotFoundException(); } return(Mapper.Map <VolatilitySettings>(updatedEntity)); }