コード例 #1
0
        public void DisplayOperatingLocation(int id, bool newLine = false, int tabIndents = 0)
        {
            string indentation = new string(' ', tabIndents * 2);

            // Get the store and address id from the operating location's data
            (int storeId, int addressId) = new Func <Tuple <int, int> >(() => {
                var tempData = StoreManagerApplication.GetData <OperatingLocation>(id) as OperatingLocationData;
                return(new Tuple <int, int>(tempData.StoreId, tempData.AddressId));
            }).Invoke();
            // Get the name of the store
            string storeName = StoreManagerApplication.GetName <Store>(storeId);

            // Get the address as a string
            Console.Write($"{(newLine ? "\n" : "")}{indentation}{storeName} - ");
            DisplayAddress(addressId);
        }
コード例 #2
0
        private void DisplayCustomerOrderHistory()
        {
            // get the customer they're looking for
            int customerId = PromptForId <Customer>();
            // get the orders of the customer they're looking for
            var customerOrders = StoreManagerApplication.GetOrderIdsByCustomerId(customerId);

            if (customerOrders.Any())
            {
                // display all of the order details
                customerOrders.ForEach(co => DisplayOrder(co, true));
            }
            else
            {
                Console.WriteLine($"No orders for '{StoreManagerApplication.GetName<Customer>(customerId)}'");
            }
        }
コード例 #3
0
        public void DisplayOrder(int orderId, bool newLine = false, int tabIndents = 0)
        {
            var    data         = StoreManagerApplication.GetData <Order>(orderId) as OrderData;
            string customerName = StoreManagerApplication.GetName <Customer>(data.CustomerId);
            // Get the addressId and storeId from the operating location
            int storeId = (StoreManagerApplication.GetData <OperatingLocation>(data.OperatingLocationId) as OperatingLocationData).StoreId;
            // get the store that owns the operating location
            string storeName = StoreManagerApplication.GetName <Store>(storeId);

            // Display the order id and display the Customer name
            Console.Write($"Order Details for Order#{orderId} from {storeName}:\n{new string(' ', (tabIndents + 1) * 2)}Customer: {customerName}");
            // Display the Operating Location
            DisplayOperatingLocation(data.OperatingLocationId, true, tabIndents + 1);
            // Display the products requested
            Console.Write($"{new string(' ', (tabIndents + 1) * 2)}Products Requested:");
            foreach (var kv in data.ProductsRequested)
            {
                DisplayProduct(kv.Key, kv.Value, true, tabIndents + 2);
            }
        }
コード例 #4
0
        protected string[] CustomerDataToStringArray(CustomerData data)
        {
            var address = (StoreManagerApplication.GetData <Address>(data.AddressId) as AddressData).ToString();
            var items   = new List <string>
            {
                //   Name
                data.Name,
                //   Email
                data.Email,
                //   PhoneNumber
                data.PhoneNumber,
                //   AddressId -> Address
                address,
                //   BirthDate
                data.BirthDate.ToString()
            };
            var defaultStoreLocation = StoreManagerApplication.GetData <OperatingLocation>(data.DefaultStoreLocationId.Value) as OperatingLocationData;
            var dslStoreName         = StoreManagerApplication.GetName <Store>(defaultStoreLocation.StoreId);
            var dslAddress           = (StoreManagerApplication.GetData <Address>(defaultStoreLocation.AddressId) as AddressData).ToString();

            items.Add($"{dslStoreName} - {dslAddress}");

            return(items.ToArray());
        }