public static string CheckInsert(int userId, string str_productId, string str_quantity)
        {
            string response = "";

            if (str_productId == "")
            {
                response = "Product ID must be filled";
            }
            else if (str_quantity == "")
            {
                response = "Quantity must be filled";
            }
            else
            {
                int productId = int.Parse(str_productId);
                int quantity  = int.Parse(str_quantity);

                if (!CartHandler.InsertCart(userId, productId, quantity))
                {
                    response = "Failed to order product";
                }
            }

            return(response);
        }
Beispiel #2
0
        public static Response InsertCart(int userId, int productId, string quantity)
        {
            if (quantity == "" || quantity.All(char.IsDigit) != true)
            {
                return(new Response(false, "Quantity cannot be empty or non numeric"));
            }
            int _quantity = Int32.Parse(quantity);

            if (CartHandler.InsertCart(userId, productId, _quantity))
            {
                return(new Response(true, "Product has been added to cart"));
            }
            return(new Response(false, "Quantity invalid"));
        }
Beispiel #3
0
        public static Response InsertCart(int UserID, int ProductID, string QuantityTxt)
        {
            if (QuantityTxt == "")
            {
                return(new Response(false, "Quantity must be filled"));
            }

            int Quantity;

            if (!int.TryParse(QuantityTxt, out Quantity))
            {
                return(new Response(false, "Quantity must be numeric"));
            }

            Quantity = int.Parse(QuantityTxt);
            if (Quantity < 1)
            {
                return(new Response(false, "Quantity must be more than 0"));
            }

            Response response = CartHandler.InsertCart(UserID, ProductID, Quantity);

            return(response);
        }