/// <summary> /// Gets a transaction amount for each company in the given collection /// of companies and returns the updated assets. /// </summary> /// <param name="assets"> /// The assets to update. /// </param> /// <param name="companies"> /// The collection of companies. /// </param> /// <returns> /// The updated assets. /// </returns> public static Assets UpdateAssets(Assets assets, IEnumerable <Company> companies) { while (true) { View.PromptEnterTransactions(); var result = Broker.Apply( assets, companies.Select(GetTransactionAmount).ToList(), companies); switch (result) { case (Assets newAssets, TransactionResult.Ok): return(newAssets); case (_, TransactionResult.Oversold): View.ShowOversold(); break; case (Assets newAssets, TransactionResult.Overspent): View.ShowOverspent(-newAssets.Cash); break; } } }