static void Run() { string indent = ConsoleFormatting.Indent(); while (true) { var consoleInput = ReadFromConsole(); if (string.IsNullOrWhiteSpace(consoleInput)) { continue; } try { Store store = new Store(); store.GetAvailableProducts(); store.GetSalesOrder(); store.CheckOut(); string result = CF.ThankYouBanner; WriteToConsole(result); } catch (Exception ex) { WriteToConsole(ex.Message); } } }
public static string Get() { var sb = new StringBuilder(); foreach (var user in SampleData.Users) { sb.AppendLine(ConsoleFormatting.Indent(2) + string.Format("Id:{0} {1} {2}", user.Id, user.FirstName, user.LastName)); } return(sb.ToString()); }
public static string Get() { var sb = new StringBuilder(); foreach (var user in SampleData.Users) { sb.Append(ConsoleFormatting.Indent(2)).AppendFormat($"Id:{user.Id} {user.FirstName} {user.LastName}").AppendLine(); } return(sb.ToString()); }
public static string DoSomethingOptional(int id, string data = "No Data Provided") { var result = string.Format(ConsoleFormatting.Indent(2) + "I did something to the record Id {0} and saved the data {1}", id, data); if (data == "No Data Provided") { result = string.Format(ConsoleFormatting.Indent(2) + "I did something to the record Id {0} but the optinal parameter " + "was not provided, so I saved the value '{1}'", id, data); } return(result); }
/// <summary> /// Gets a list of available products so user is aware of choices /// </summary> /// <returns>list of available products</returns> public static string Get() { string indent = ConsoleFormatting.Indent(); var sb = new StringBuilder(); foreach (var product in ap.AvailableProducts) { sb.AppendLine($"{indent}Product Name: {product.ProductName}, Product Price: {product.ProductPrice:C}"); } Console.WriteLine($"{indent}Your Available Products\n"); return(sb.ToString()); }
// Methods used as console commands must be public and must return a string public static string help() { string output = "--------\r\n" + ConsoleFormatting.Indent(1) + "options\r\n--------"; foreach (KeyValuePair <string, Dictionary <string, IEnumerable <ParameterInfo> > > kvp in Program._commandLibraries) { foreach (KeyValuePair <string, IEnumerable <ParameterInfo> > methods in kvp.Value) { output += "\r\n" + ConsoleFormatting.Indent(1) + methods.Key; if (methods.Value.Count() > 0) { output += "\r\nParameters:"; foreach (ParameterInfo info in methods.Value) { output += "\r\n" + ConsoleFormatting.Indent(1) + "- " + info.Name; } } output += "\r\n"; } } return(output); }
public static string DoSomethingElse(DateTime date) { return(string.Format(ConsoleFormatting.Indent(2) + "I did something else on {0}", date)); }
// Methods used as console commands must be public and must return a string public static string DoSomething(int id, string data) { return(string.Format(ConsoleFormatting.Indent(2) + "I did something to the record Id {0} and saved the data '{1}'", id, data)); }