Ejemplo n.º 1
0
            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))
                });
            }
Ejemplo n.º 2
0
 public static OffchainGroupsByAsset Create(IEnumerable <IGroup> groups, IReadOnlyDictionary <string, IAssetDefinition> assetDictionary)
 {
     return(Create(groups.Select(p => OffchainGroupViewModel.Create(p, assetDictionary))));
 }