private async Task AddClientToGroupAsync(string clientId, IAssetGroup assetGroup, bool replace) { var assetClientGroupLink = new ClientAssetGroupLink { ClientId = clientId, ClientsCanCashInViaBankCards = assetGroup.ClientsCanCashInViaBankCards, GroupName = assetGroup.Name, IsIosDevice = assetGroup.IsIosDevice, SwiftDepositEnabled = assetGroup.SwiftDepositEnabled }; var assetGroupClientLink = new AssetGroupClientLink { ClientId = clientId, ClientsCanCashInViaBankCards = assetGroup.ClientsCanCashInViaBankCards, GroupName = assetGroup.Name, IsIosDevice = assetGroup.IsIosDevice, SwiftDepositEnabled = assetGroup.SwiftDepositEnabled }; if (replace) { await _clientAssetGroupLinkRepository.AddOrReplaceAsync(assetClientGroupLink); await _assetGroupClientLinkRepository.AddOrReplaceAsync(assetGroupClientLink); } else { await _clientAssetGroupLinkRepository.AddAsync(assetClientGroupLink); await _assetGroupClientLinkRepository.AddAsync(assetGroupClientLink); } await _cacheManager.RemoveClientFromCacheAsync(clientId); }
public async Task EditGroup(IAssetGroup assetGroup) { var entity = AssetGroupEntity.Record.Create(assetGroup); await _tableStorage.InsertOrMergeAsync(entity); var updatedGroup = await _tableStorage.GetDataAsync(AssetGroupEntity.Record.GeneratePartitionKey(), AssetGroupEntity.Record.GenerateRowKey(assetGroup.Name)); var clients = (await GetClientIdsForGroup(assetGroup.Name)).ToArray(); if (clients.Any()) { foreach (var clientId in clients) { var clientGroupLink = await _tableStorage .GetDataAsync(AssetGroupEntity.ClientGroupLink.GeneratePartitionKey(updatedGroup.Name), AssetGroupEntity.ClientGroupLink.GenerateRowKey(clientId)); AssetGroupEntity.ClientGroupLink.Update(clientGroupLink, updatedGroup); var groupClientLink = await _tableStorage .GetDataAsync(AssetGroupEntity.GroupClientLink.GeneratePartitionKey(clientId), AssetGroupEntity.GroupClientLink.GenerateRowKey(updatedGroup.Name)); AssetGroupEntity.GroupClientLink.Update(groupClientLink, updatedGroup); await _tableStorage.InsertOrMergeAsync(clientGroupLink); await _tableStorage.InsertOrMergeAsync(groupClientLink); } } }
public async Task UpdateAsync(string assetId, IAssetGroup group) { await _assetGroupTable.MergeAsync(GetPartitionKey(group.Name), GetRowKey(assetId), x => { Mapper.Map(group, x); return(x); }); }
public async Task AddAsync(IAssetGroup group) { var entity = Mapper.Map <AssetGroupEntity>(group); entity.PartitionKey = GetPartitionKey(); entity.RowKey = GetRowKey(group.Name); await _assetGroupTable.InsertAsync(entity); }
public AssetGroupShould() { InjectComponentsArray(Array.Empty <IComponent>()); var assets = Fixture.CreateMany <TestAsset>().ToArray(); _asset = assets[0]; _assetCount = assets.Length; _assetGroup = new AssetGroup <TestAsset>(assets.Cast <Asset>().ToArray()); }
public static void AreEquivalent(this Assert assert, IAssetGroup expected, AssetGroup actual) { if (expected.ClientsCanCashInViaBankCards != actual.ClientsCanCashInViaBankCards || expected.IsIosDevice != actual.IsIosDevice || expected.Name != actual.Name || expected.SwiftDepositEnabled != actual.SwiftDepositEnabled) { throw new AssertFailedException("Asset extended infos do not match."); } }
public static AssetGroupEntity Create(IAssetGroup assetGroup) { return(new AssetGroupEntity { RowKey = GenerateRowKey(assetGroup.Name), PartitionKey = GeneratePartitionKey(), Name = assetGroup.Name, IsIosDevice = assetGroup.IsIosDevice, ClientsCanCashInViaBankCards = assetGroup.ClientsCanCashInViaBankCards }); }
public async Task UpdateGroupAsync(IAssetGroup group) { var tasks = new List <Task>(); var assetLinksTasks = (await GetAssetIdsForGroupAsync(group.Name)).Select(assetId => _assetGroupAssetLinkRepository.UpdateAsync(assetId, group)); tasks.AddRange(assetLinksTasks); var clientIds = (await GetClientIdsForGroupAsync(group.Name)).ToArray(); var clientAssetGroupTasks = clientIds.Select(clientId => _clientAssetGroupLinkRepository.UpdateAsync(clientId, group)); tasks.AddRange(clientAssetGroupTasks); var assetGroupTasks = clientIds.Select(clientId => _assetGroupClientLinkRepository.UpdateAsync(clientId, group)); tasks.AddRange(assetGroupTasks); tasks.Add(_assetGroupRepository.UpdateAsync(group)); await Task.WhenAll(tasks.ToArray()); await _cacheManager.ClearCacheAsync($"UpdateGroupAsync {group.Name}"); }
public void AddGroup <TAsset>(IAssetGroup <TAsset> assetGroup) where TAsset : Asset { var groupId = Typeof <TAsset> .Id; _groups.Add(groupId, assetGroup); }
public static void Update(AssetGroupEntity entity, IAssetGroup assetGroup) { entity.Name = assetGroup.Name; entity.ClientsCanCashInViaBankCards = assetGroup.ClientsCanCashInViaBankCards; entity.IsIosDevice = assetGroup.IsIosDevice; }
public async Task <IAssetGroup> AddGroupAsync(IAssetGroup group) { await _assetGroupRepository.AddAsync(group); return(group); }
public async Task AddClientToGroupOrReplaceAsync(string clientId, IAssetGroup assetGroup) { await AddClientToGroupAsync(clientId, assetGroup, true); }
// TODO: Obsolete public async Task AddClientToGroupAsync(string clientId, IAssetGroup assetGroup) { await AddClientToGroupAsync(clientId, assetGroup, false); }