//GET  /Customer/Choose
        /// <summary>
        /// Display a list of all customers that you can search by name
        /// </summary>
        /// <param name="repo">The repository of info, pulled from DB</param>
        /// <param name="searchString">Filters list of customers to only the ones with the searchString in their name</param>
        /// <returns></returns>
        public ActionResult Choose([FromServices] IDbRepository repo, string searchString)
        {
            /* List of customers as CustomerViewModel in an IEnumerable*/
            List <CustomerViewModel> allCustomers = new List <CustomerViewModel>();

            foreach (var c in repo.GetCustomers().ToList())
            {
                //ensure it's been loaded
                if (c.CustomerOrderHistory.Count() == 0)
                {
                    repo.GetOrderHistory(c);
                }

                allCustomers.Add(StoreToViewMapper.MapCustomerToView(c));
            }

            //filtered by search string
            if (!string.IsNullOrEmpty(searchString))
            {
                allCustomers = allCustomers.Where(
                    cust => cust.Name.Contains(searchString)).ToList();
            }

            return(View(allCustomers));
        }
        // GET: Customer/Edit/5
        public ActionResult Edit([FromServices] IDbRepository repo, string customerName)
        {
            CustomerViewModel customerViewModel = null;

            if (string.IsNullOrWhiteSpace(customerName))
            {
                _logger.LogError("Bad Customer Name given.");
                return(View(nameof(Choose)));
            }
            else
            {
                customerViewModel = StoreToViewMapper.MapCustomerToView(
                    repo.GetCustomerByName(new Name(customerName))
                    );
            }


            ViewData["Stores"] = GetStoreNames(repo);
            return(View(customerViewModel ?? new CustomerViewModel()));
        }
        // GET: Customer/Details/5
        // view order history and other details
        public ActionResult Details([FromServices] IDbRepository repo, string customerName)
        {
            if (string.IsNullOrWhiteSpace(customerName))
            {
                //todo: set error thing to display on the view, could not find customer
                ModelState.TryAddModelError("customerName", "Invalid name given, it's null, or just space");
                _logger.Log(LogLevel.Error, "Invalid name given, it's null, or just space");
                return(RedirectToAction(nameof(Choose)));
            }
            else
            {
                Store.Customer c = repo.GetCustomerByName(new Name(customerName));

                /* get the order history from the repo into the model
                 * incase a new one has been placed since the model was loaded.
                 * Utilized in the mapper to fill in the object.
                 */
                repo.GetOrderHistory(c);

                CustomerViewModel customer = StoreToViewMapper.MapCustomerToView(c);

                return(View(customer));
            }
        }