public void GetAllCustomers() { var customers = storeRepo.GetCustomers(); Console.WriteLine($"Customer ID\t\tFirst Name\t\tLast Name\t\tEmail"); foreach (var customer in customers) { Console.WriteLine($"{customer.CustomerId}\t\t\t{customer.FirstName}\t\t\t{customer.LastName}\t\t\t{customer.Email}"); } }
//GET - Customer public IActionResult Index(string searchString) { var customers = _storeRepo.GetCustomers(); if (!String.IsNullOrEmpty(searchString)) { string[] nameList = searchString.Split(' '); ///[firstname, lastname] string firstName = nameList[0]; string lastName = nameList[1]; customers = _storeRepo.GetCustomerByName(firstName, lastName); return(View(customers)); } return(View(customers)); }
//CREATE public ActionResult Create() { var locations = _storeRepo.GetLocations(); var customers = _storeRepo.GetCustomers(); var newOrder = new OrderViewModel(); foreach (var customer in customers) { newOrder.Customers.Add(customer); } foreach (var location in locations) { newOrder.Locations.Add(location); } ; return(View(newOrder)); }