public static Group Create(OffchainGroupViewModel source, string currentUncoloredAddress) { Func <OffchainTransactionViewModel, decimal> qtySelector; var latestOffchainTx = source.OffChainTransactions.OrderBy(p => p.DateTime).Last(); if (latestOffchainTx.Address1 == currentUncoloredAddress) { qtySelector = p => p.Address1Quantity; } else if (latestOffchainTx.Address2 == currentUncoloredAddress) { qtySelector = p => p.Address2Quantity; } else { throw new Exception("Invalid condition"); } return(new Group { Asset = source.Asset, Transactions = source.OffChainTransactions .Select(p => Transaction.Create(p, qtySelector)) }); }
public static OffchainGroupsByAsset Create(IEnumerable <IGroup> groups, IReadOnlyDictionary <string, IAssetDefinition> assetDictionary) { return(Create(groups.Select(p => OffchainGroupViewModel.Create(p, assetDictionary)))); }