public async Task UpdateAsync(IAsset asset) { await ValidateAsset(asset); await _assetRepository.UpdateAsync(asset); await _myNoSqlWriter.TryInsertOrReplaceAsync(AssetNoSql.Create(asset)); //todo: remove cqrs _cqrsEngine.SendCommand( new UpdateAssetCommand { Asset = Mapper.Map <Asset>(asset) }, BoundedContext.Name, BoundedContext.Name); }
IAsset IAssetsClient.Get(string assetId) { try { var data = _readerAssetNoSql.Get( AssetNoSql.GeneratePartitionKey(), AssetNoSql.GenerateRowKey(assetId)); return(data?.Asset); } catch (Exception ex) { Console.WriteLine($"Cannot read from MyNoSQL. Table: ${AssetNoSql.TableName}, PK: {AssetNoSql.GeneratePartitionKey()}, RK: {AssetNoSql.GenerateRowKey(assetId)}, Ex: {ex}"); throw; } }
public async Task RemoveAsync(string id) { await _assetRepository.RemoveAsync(id); await _myNoSqlWriter.TryDeleteAsync(AssetNoSql.GeneratePartitionKey(), AssetNoSql.GenerateRowKey(id)); }