コード例 #1
0
        /// <summary>
        /// This takes a DB context and allows the user to view the order history of a particular location
        /// </summary>
        /// <param name="context"></param>
        public static void LocationHistory(Project0Context context)
        {
            Console.WriteLine("Please enter the NUMBER of the location you'd like to see the order history of.");
            var locations = DBRepository.ReadAllLocations(context);

            foreach (var item in locations)
            {
                Console.WriteLine($"\t{item.LocationId}---{item.LocationName}");
            }
            string response  = Console.ReadLine();
            int    response1 = Convert.ToInt32(response);

            //get all orders and sort them by locationID
            var locOrders = context.Orders.Where(x => x.LocationId == response1).ToList();

            foreach (var item in locOrders)
            {
                Console.WriteLine($"\tLocationID => {item.LocationId}-----OrderID => {item.OrderId}-----CustomerID => {item.CustomerId}---");
            }
            Console.WriteLine("This is the order history of this location");
        }
コード例 #2
0
        /// <summary>
        /// This takes a DB context and allows the user to view the order history of a particular location
        /// </summary>
        /// <param name="context"></param>
        public static void LocationHistory(DBRepository repo)
        {
            Console.WriteLine("Please enter the NUMBER of the location you'd like to see the order history of.");
            var locations = repo.ReadAllLocations();

            foreach (var item in locations)
            {
                Console.WriteLine($"\t{item.LocationId}---{item.LocationName}");
            }
            string response  = Console.ReadLine();
            int    response1 = Convert.ToInt32(response);

            //get all orders and sort them by locationID
            var locOrders = repo.ReadAllOrdersInTable();

            foreach (var item in locOrders)
            {
                Console.WriteLine($"\tLocationID => {item.LocationId}-----OrderID => {item.OrderId}-----CustomerID => {item.CustomerId}---");
            }
            Console.WriteLine("This is the order history of this location");
        }