/// <summary> /// Handle input. /// </summary> public void InputLoop() { var inputOptions = CliInput.GetLineOptions.TrimSpaces | CliInput.GetLineOptions.AcceptEmpty; do { Console.Write("\n\n"); var line = CliInput.GetLine(inputOptions, v => true, "Sort by [D]ate / [P]rice / [S]tore\nor enter an order number to view details:"); switch (line) { case "D": case "d": this.SortKey = this.SortKey != OrderSortKey.DateDesc ? OrderSortKey.DateDesc : OrderSortKey.DateAsc; break; case "P": case "p": this.SortKey = this.SortKey != OrderSortKey.PriceDesc ? OrderSortKey.PriceDesc : OrderSortKey.PriceAsc; break; case "S": case "s": this.SortKey = this.SortKey != OrderSortKey.LocationAsc ? OrderSortKey.LocationAsc : OrderSortKey.LocationDesc; break; default: if (line == "" || line == null) { this.MenuExit(); return; } try { var orderNum = Int32.Parse(line); if (orderNum > 0 && orderNum <= this.OrderIds.Count) { using (var db = new StoreContext(this.ApplicationState.DbOptions)) { var order = db.GetOrderById(this.OrderIds[orderNum - 1]); var amountCharged = db.GetAmountCharged(order); this.DisplayDetail(db, order, amountCharged); break; } } else { break; } } catch (Exception) { // We will just ignore parse errors and reprint the menu. break; } } this.PrintMenu(); } while (true); }
/// <summary> /// Create this menu. /// </summary> /// <param name="appState">Global application state.</param> /// <returns>This menu.</returns> public OrderHistory(ApplicationData.State appState) : base(appState) { this.SortKey = OrderSortKey.DateDesc; }