internal static List <Order> GetPastOrdersFromCustomer(Customer customer, P1Context _context)
        {
            List <Order> OrdersByCustomer = new List <Order>();

            var DB = _context;

            OrderDAO.LoadOrdersList(DB);
            OrderProductsDAO.LoadOrderProductsList(DB);
            ProductDAO.LoadProductsList(DB);
            LocationDAO.LoadLocationsList(DB);
            BillingDAO.LoadBillingList(DB);
            CustomerDAO.LoadCustomersList(DB);
            ShippingDAO.LoadShippingInfomrationList(DB);

            OrdersByCustomer = DB.OrdersList.Where(o => o.CustomerID == customer.CustomerID).ToList();

            for (int i = 0; i < OrdersByCustomer.Count; i++)
            {
                Order o = OrdersByCustomer[i];

                List <ProductInStock> prodsOrdered = new List <ProductInStock>();

                List <OrderProducts> prodIDsAndQuantityInOrder = DB.OrderProductsList.Where(op => op.OrderID == OrdersByCustomer[i].OrderID).ToList();
                foreach (OrderProducts OP in prodIDsAndQuantityInOrder)
                {
                    ProductInStock prodOrdered = new ProductInStock();
                    Product        p           = DB.ProductsList.First(p => p.ProductID == OP.ProductID);
                    prodOrdered.Name        = p.Name;
                    prodOrdered.Price       = p.Price;
                    prodOrdered.Description = p.Description;
                    prodOrdered.Quantity    = OP.Quantity;
                    prodsOrdered.Add(prodOrdered);
                }

                o.ShoppingCart = prodsOrdered;

                o.Billing = DB.BillingInformationList.First(b => b.BillingID == OrdersByCustomer[i].BillingID);

                o.Shipping = DB.ShippingInformation.First(s => s.ShippingID == OrdersByCustomer[i].ShippingID);

                o.Location = DB.LocationList.First(l => l.LocationID == OrdersByCustomer[i].LocationID);

                o.Customer = DB.CustomersList.First(c => c.CustomerID == OrdersByCustomer[i].CustomerID);

                OrdersByCustomer[i] = o;
            }
            return(OrdersByCustomer);
        }
        public static Shipping GetAddress(int ShippingID, P1Context _context)
        {
            Shipping addy = new Shipping();
            var      DB   = _context;

            ShippingDAO.LoadShippingInfomrationList(DB);
            foreach (Shipping a in DB.ShippingInformationList)
            {
                if (a.ShippingID == ShippingID)
                {
                    addy = a;
                    break;
                }
            }
            return(addy);
        }
        internal static List <Shipping> GetShippingAddresssesOnFileForCustomer(Customer customer, P1Context _context)
        {
            List <Shipping> ships = new List <Shipping>();
            var             DB    = _context;

            CustomerShippingDAO.LoadCustomersShippingList(DB);
            ShippingDAO.LoadShippingInfomrationList(DB);

            foreach (CustomerShipping cs in DB.CustomerShippingList)
            {
                if (cs.CustomerID == customer.CustomerID)
                {
                    foreach (Shipping s in DB.ShippingInformationList)
                    {
                        if (cs.ShippingID == s.ShippingID)
                        {
                            ships.Add(s);
                        }
                    }
                }
            }
            return(ships);
        }