示例#1
0
        private static void searchAccount()
        {
            var  accounts = ReadAccounts().ToList();
            var  table    = new TablePrinter("Number", "Balance", "Label", "Owner Id");
            bool exists   = false;

            Console.Clear();
            Console.WriteLine("\r\n Enter search statement:");
            var input = RemoveWhitespace(Console.ReadLine(), true);

            var matches = accounts.Where(c =>
                                         c.Number.ToString().Contains(input) ||
                                         c.Label.ToString().ToLower().Contains(input.ToLower()) ||
                                         c.Owner.ToString().Contains(input));

            if (IsAny(matches))
            {
                foreach (var Account in matches)
                {
                    table.AddRow(Account.Number, Account.Balance, Account.Label, Account.Owner);
                    exists = true;
                }
            }

            if (exists)
            {
                table.Print();
                Console.WriteLine("\nPress any key to return to menu");
                Console.ReadKey();
            }
            else
            {
                Console.WriteLine("No annount found");
                Console.WriteLine("\nPress any key to return to menu");
                Console.ReadKey();
            }
        }