示例#1
0
        static void DisplayLocationHistory(IProject0Repository projectRepository)
        {
            _io.Output("Select an Location: \n");
            var locations    = projectRepository.GetLocations();
            var locationList = locations.ToList <StoreLocation>();
            int locationId   = 0;

            while (locationId == 0)
            {
                foreach (var item in locationList)
                {
                    _io.Output(item.LocationName + "\n");
                }
                string locationInput = _io.Input();
                try
                {
                    //get store id
                    locationId = locations.First(l => l.LocationName.ToLower() == locationInput).Id;
                }
                catch (ArgumentException ex)
                {
                    _io.Output("Location Id Invalid.");
                    s_logger.Info(ex);
                    Console.WriteLine(ex.Message);
                }
            }
            var orderHistory = projectRepository.GetOrders().Where(o => o.StoreLocationId == locationId).ToList();

            foreach (var item in orderHistory)
            {
                var productName  = projectRepository.GetProductById(item.ProductId).Name;
                var customerName = projectRepository.GetCustomerById(item.CustomerId).FirstName + " " + projectRepository.GetCustomerById(item.CustomerId).LastName;
                var locationName = projectRepository.GetLocationsById(item.CustomerId).LocationName;
                _io.Output($"ID: {item.Id} Product Name: {productName} Quantity: {item.Quantity} " +
                           $" Customer Name: {customerName} \n");
            }
        }