private void ReadCommand() { while (true) { try { ConsoleManager.WriteLine("\nEnter command:\n"); ConsoleManager.ChangeColor(ConsoleColor.Blue); IList <string> parameters = ConsoleManager.ReadLine().Split().ToList(); string result = CommandProcessor.ProcessCurrentCommand(parameters); ConsoleManager.WriteLine(result, ConsoleColor.Green); ConsoleManager.ResetColor(); if (parameters[0] == "exit") { Environment.Exit(0); } } catch (InitialCustomException ice) { ConsoleManager.WriteLine(ice.Message, ConsoleColor.Red); } catch (Exception ex) { ConsoleManager.WriteLine(ex.Message, ConsoleColor.Red); } } }
public void PrintMarket(IUser user, IMarket market) { ConsoleManager.Clear(); PrintMarketName(); List <IMarketAssetPrice> ordered = market.AssetPrices.OrderBy(x => x.Category).ToList(); string category = ""; PrintUserInfo(user); for (int i = 0; i < ordered.Count; i++) { if (ordered[i].Category != category) { ConsoleManager.WriteLine(); category = ordered[i].Category; ConsoleManager.WriteAligned("\n{0,20} => ", category); } ConsoleManager.WriteAligned("{0,15} ", $"{ordered[i].Name}: "); string key = ordered[i].Name.First().ToString().ToUpper() + ordered[i].Name.Substring(1); if (user.Wallet.Portfolio.ContainsKey(key)) { if (user.Wallet.Portfolio[key].Price < ordered[i].Price) { ConsoleManager.ChangeColor(ConsoleColor.Green); } else if (user.Wallet.Portfolio[key].Price > ordered[i].Price) { ConsoleManager.ChangeColor(ConsoleColor.Red); } } ConsoleManager.WriteAligned("{0,7 } ", $"${ordered[i].Price}"); ConsoleManager.ResetColor(); ConsoleManager.Write("| "); } ConsoleManager.WriteLine("\n"); }