public void GetCustomers()
        {
            Console.WriteLine("Enter your full name");
            string name      = Console.ReadLine();
            var    customers = _customerBL.GetCustomersByName(name);

            if (customers.Any())
            {
                if (customers.Count == 1)
                {
                    Program.currentCustomer = customers.First();
                }

                else
                {
                    int count = 1;
                    foreach (var item in customers)
                    {
                        Console.WriteLine($"{count} - Name: {item.Name} Age: {item.Age} ");
                        count++;
                    }
                    Console.WriteLine($"Multiple matches found: {customers.Count}, please select the corresponding number to your name");

                    string identity    = Console.ReadLine();
                    int    identityNum = int.Parse(identity);
                    Program.currentCustomer = customers.ToArray()[identityNum - 1];
                }
                var beermenu = new BeerMenu(_inventoryBL, _orderBL);
                beermenu.Start();
            }
            else
            {
                Console.WriteLine("No customer found with those credentials.");
            }
        }
예제 #2
0
        // GET: CustomerController
        public ActionResult Index(string searchName = null)
        {                                                                                                                                 // loads the index page for customer
            var customers = string.IsNullOrWhiteSpace(searchName)?_customerBL.GetCustomers(): _customerBL.GetCustomersByName(searchName); //else after colon
            // if you have a searchname, call getcustomersbyname...if you dont then get all the customers
            var customerVMs = new List <CustomerVM>();

            foreach (var item in customers)
            {
                var customerVM = _mapper.Map <CustomerVM>(item);
                customerVMs.Add(customerVM);
            }
            var customerIndexVM = new CustomerIndexVM();

            customerIndexVM.Customers = customerVMs;
            return(View(customerIndexVM));
        }