public static Boolean ProductValidation(string name, string stock, string price, string typeId, out string errorMessage) { errorMessage = ""; if (name == String.Empty || price == String.Empty || typeId == string.Empty || stock == string.Empty) { errorMessage = "All fields must be filled in"; return(false); } else if (Int32.Parse(stock) < 1) { errorMessage = "Stock must be more than 1"; return(false); } else if (Int32.Parse(price) < 1000 || Int32.Parse(price) % 1000 != 0) { errorMessage = "Price must be more than 1000 and multiple of 1000"; return(false); } else if (InsertProductHandler.CheckProductTypeHandler(Int32.Parse(typeId)) == false) { errorMessage = "Product type not found"; return(false); } return(true); }
public static Response DoInsertProduct(String TypeID, String Name, int Price, int Stock, Int64 ID) { if (Name == "") { return(new Response(false, "Product Name Cannot Be Empty")); } if (Stock <= 0) { return(new Response(false, "Product Stock Must Be 1 Or More")); } if (Price <= 1000) { return(new Response(false, "Product Price Must Be Above 1000 and Multiply of 1000")); } if (Price % 1000 != 0) { return(new Response(false, "Product Price Must Be Above 1000 and Multiply of 1000")); } if (TypeID == "") { return(new Response(false, "Product Type ID Cannot Be Empty")); } Response response = InsertProductHandler.DoInsertProduct(TypeID, Name, Price, Stock, ID); return(response); }
public static void InsertNewProductController(string name, int productType, int stock, int price) { InsertProductHandler.InsertNewProductHandler(name, productType, stock, price); }
public static List <ProductType> GetAllProductTypeController() { return(InsertProductHandler.GetAllProductTypeHandler()); }
public static ProductType SearchByName(string type) { return(InsertProductHandler.SearchByName(type)); }
public static void doInsert(int id, string name, int price, int stock) { InsertProductHandler.InsertProduct(id, name, price, stock); }
public static List <ProductType> getAllProductType() { return(InsertProductHandler.getAllProductType()); }
public static int CountData() { int ID = InsertProductHandler.CountData(); return(ID); }