Example #1
0
        public void SetPropertyOfAssetEntity(SetPropertyForAssetRequestModel propertyForAssetRequestModel, AssetEntity entity)
        {
            var prop = propertyForAssetRequestModel.Property;

            if (prop == "is cash")
            {
                entity.IsCash = propertyForAssetRequestModel.Value;
            }

            else if (prop == "is fixincome")
            {
                entity.IsFixIncome = propertyForAssetRequestModel.Value;
            }

            else if (prop == "is convertible")
            {
                entity.IsConvertible = propertyForAssetRequestModel.Value;
            }

            else if (prop == "is swap")
            {
                entity.IsSwap = propertyForAssetRequestModel.Value;
            }

            else if (prop == "is future")
            {
                entity.IsFuture = propertyForAssetRequestModel.Value;
            }
            else
            {
                logger.LogError($"Model property could not be found in AssetPropertySetter  {prop}");
                throw new PropertySetException($"Property of {prop} could not be found");
            }
        }
        public async Task SetPropertyForAsset(SetPropertyForAssetRequestModel model)
        {
            var currentAsset = imDbContext.Assets.SingleOrDefault(a => a.AssetId == model.AssetId);

            if (currentAsset == null)
            {
                logger.LogError($"AssetId can not be found {model.AssetId}");
            }
            else if (currentAsset.TimeStamp > model.TimeStamp)
            {
                logger.LogWarning($"Asset has smaller timestamp so skipping. AssetID : {model.AssetId}");
            }
            else
            {
                assetPropertySetter.SetPropertyOfAssetEntity(model, currentAsset);
            }
            imDbContext.Update(currentAsset);
            await imDbContext.SaveChangesAsync();
        }
 public async Task SetPropertyForAsset(SetPropertyForAssetRequestModel model)
 {
     await assetRepository.SetPropertyForAsset(model);
 }