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); } }
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)); }
public static DetailCart GetCart(String UserID, String ProductID) { return(UpdateCartHandler.GetCart(UserID, ProductID)); }