Beispiel #1
0
        internal static List <Billing> GetCardsOnFileForCustomer(Customer CurrentCustomer)
        {
            List <Billing> CardOptions = new List <Billing>();

            using (var DB = new P0Context())
            {
                CustomerBillingDAO.LoadCustomersBillingList(DB);
                BillingDAO.LoadBillingList(DB);

                foreach (CustomerBilling cb in DB.CustomerBillingList)
                {
                    if (cb.CustomerID == CurrentCustomer.CustomerID)
                    {
                        foreach (Billing b in DB.BillingInformationList)
                        {
                            if (cb.BillingID == b.BillingID)
                            {
                                CardOptions.Add(b);
                            }
                        }
                    }
                }
            }
            return(CardOptions);
        }
Beispiel #2
0
 internal static void AddNewCardInformationToUser(Billing CardInfoEntered, Customer CurrentCustomer)
 {
     using (var DB = new P0Context())
     {
         BillingDAO.AddBilling(CardInfoEntered, DB);
         CustomerBilling CB = new CustomerBilling
         {
             CustomerID = CurrentCustomer.CustomerID,
             BillingID  = CardInfoEntered.BillingID
         };
         CustomerBillingDAO.AddCustomerBilling(CB, DB);
     }
 }
        internal static void AddNewCardInformationToUser(Billing CardInfoEntered, Customer CurrentCustomer, P1Context _context)
        {
            var DB = _context;

            BillingDAO.AddBilling(CardInfoEntered, DB);
            CustomerBilling CB = new CustomerBilling
            {
                CustomerID = CurrentCustomer.CustomerID,
                BillingID  = CardInfoEntered.BillingID
            };

            CustomerBillingDAO.AddCustomerBilling(CB, DB);
        }
        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 Billing GetCard(int BillingID, P1Context _context)
        {
            Billing card = new Billing();
            var     DB   = _context;

            BillingDAO.LoadBillingList(DB);
            foreach (Billing b in DB.BillingInformationList)
            {
                if (b.BillingID == BillingID)
                {
                    card = b;
                    break;
                }
            }
            return(card);
        }