Exemple #1
0
        public async Task <IAssetGeneralSettings> SetAsync(IAssetGeneralSettings availability)
        {
            string partitionKey = AssetGeneralSettingsEntity.ByAsset.GeneratePartitionKey(availability.AssetId);
            string rowKey       = AssetGeneralSettingsEntity.ByAsset.GenerateRowKey(availability.AssetId);

            AssetGeneralSettingsEntity exItem = await _tableStorage.GetDataAsync(partitionKey, rowKey);

            if (exItem != null)
            {
                AssetGeneralSettingsEntity merged = await _tableStorage.MergeAsync(partitionKey, rowKey, item =>
                {
                    item.PaymentAvailable    = availability.PaymentAvailable;
                    item.SettlementAvailable = availability.SettlementAvailable;
                    item.AutoSettle          = availability.AutoSettle;
                    item.Network             = availability.Network;

                    return(item);
                });

                return(Mapper.Map <AssetGeneralSettings>(merged));
            }

            var newItem = AssetGeneralSettingsEntity.ByAsset.Create(availability);

            await _tableStorage.InsertAsync(newItem);

            return(Mapper.Map <AssetGeneralSettings>(newItem));
        }
Exemple #2
0
        public async Task <IAssetGeneralSettings> GetAsync(string assetId)
        {
            AssetGeneralSettingsEntity entity = await _tableStorage.GetDataAsync(
                AssetGeneralSettingsEntity.ByAsset.GeneratePartitionKey(assetId),
                AssetGeneralSettingsEntity.ByAsset.GenerateRowKey(assetId));

            return(Mapper.Map <AssetGeneralSettings>(entity));
        }