Ejemplo n.º 1
0
        public static void insertTransaction(List <Cart> carts, int paymentTypeID, int UserID)
        {
            TransactionRepo.addHeaderTransaction(TransactionFactory.createHeaderTransaction(UserID, paymentTypeID));
            int transactionId = TransactionRepo.getLastTransactionID();

            for (int i = 0; i < carts.Count; i++)
            {
                Product product = ProductHandler.get(carts[i].ProductID);
                if (carts[i].Quantity <= product.Stock)
                {
                    ProductHandler.updateProductStock(carts[i].ProductID, carts[i].Quantity);
                    TransactionRepo.addDetailTransaction(TransactionFactory.createDetailTransaction(transactionId, carts[i].ProductID, carts[i].Quantity));
                }
            }
        }
Ejemplo n.º 2
0
        public static List <CartInformation> getCartCustomView(int UserID)
        {
            var cart_List            = CartRepo.getCartCustomView(UserID);
            var cartInformation_List = new List <CartInformation>();

            for (int i = 0; i < cart_List.Count; i++)
            {
                CartInformation CInfo = new CartInformation();
                CInfo.ID       = cart_List[i].ProductID;
                CInfo.Name     = ProductHandler.getName(cart_List[i].ProductID);
                CInfo.Price    = ProductHandler.getPrice(cart_List[i].ProductID);
                CInfo.Quantity = getQuantity(UserID, cart_List[i].ProductID);
                CInfo.SubTotal = (ProductHandler.getPrice(cart_List[i].ProductID) * cart_List[i].Quantity);
                cartInformation_List.Add(CInfo);
            }
            return(cartInformation_List);
        }