public static bool validateUpdate(int userID, int productID, int qty, out string errorMsg)
        {
            int totalReserved = qty + AddtoCartHandler.getQuantity(productID);
            var total         = AddtoCartHandler.getStock(productID);

            errorMsg = "";
            if (qty < 0)
            {
                errorMsg = "Input must be higher than 0";
                return(false);
            }
            else if (qty == 0)
            {
                UpdateCartHandler.deleteCart(userID, productID);
                return(true);
            }
            else if (qty > total.Select(p => p.Stock).FirstOrDefault() || totalReserved > total.Select(p => p.Stock).FirstOrDefault())
            {
                errorMsg = "Stock not available";
                return(false);
            }
            else
            {
                UpdateCartHandler.updateQuantity(userID, productID, qty);
                return(true);
            }
        }
示例#2
0
 public static Response UpdateCart(String UserID, string ProductID, int Qty)
 {
     if (Qty < 0)
     {
         return(new Response(false, "Quantity Cannot Below Zero Number"));
     }
     if (Qty == 0)
     {
         DeleteProductCartHandler.DoDeleteProductCart(UserID, ProductID);
         return(new Response(true));
     }
     return(UpdateCartHandler.UpdateCart(UserID, ProductID, Qty));
 }
 public static List <DetailedCart> getSelectedCart(int userID, int productID)
 {
     return(UpdateCartHandler.getSelectedCart(userID, productID));
 }
示例#4
0
 public static DetailCart GetCart(String UserID, String ProductID)
 {
     return(UpdateCartHandler.GetCart(UserID, ProductID));
 }