public static int CreateBrand(String BrandName, ref List <string> errors) { if (BrandName == null) { errors.Add("Brand name cannot be null"); return(-1); } List <BrandInfo> pi = DALBrand.ReadBrandList(ref errors); for (int i = 0; i < pi.Count; i++) { if (BrandName.ToLower() == pi[i].brand_name.ToLower()) { errors.Add("Brand name already exists"); } } if (errors.Count > 0) { return(-1); } return(DALBrand.CreateBrand(BrandName, ref errors)); }
public static int UpdateBrand(int BrandId, string BrandName, ref List <string> errors) { if (BrandId <= 0 || BrandId > DALBrand.ReadBrandList(ref errors).Count) { errors.Add("Invalid Brand id"); } if (errors.Count > 0) { return(-1); } return(DALBrand.UpdateBrand(BrandId, BrandName, ref errors)); }
public static BrandInfo ReadBrand(int BrandId, ref List <string> errors) { if (BrandId <= 0 || BrandId > DALBrand.ReadBrandList(ref errors).Count) { errors.Add("Invalid Brand id"); } if (errors.Count > 0) { return(null); } return(DALBrand.ReadBrandDetail(BrandId, ref errors)); }
public void CreateBrandTest() { Random rand = new Random(); string Brand_name = "Hello Kitty" + rand.Next(10000); // TODO: Initialize to an appropriate value List <string> errors = new List <string>(); // TODO: Initialize to an appropriate value List <string> errorsExpected = new List <string>(); // TODO: Initialize to an appropriate value int actual; actual = DALBrand.CreateBrand(Brand_name, ref errors); BrandInfo pi = DALBrand.ReadBrandDetail(actual, ref errors); Assert.AreEqual(pi.brand_name, Brand_name); Assert.AreEqual(pi.brand_id, actual); }
public void ReadAllBrandTest() { List <string> errors = new List <string>(); // TODO: Initialize to an appropriate value List <string> errorsExpected = new List <string>(); // TODO: Initialize to an appropriate value List <BrandInfo> BrandList1 = DALBrand.ReadBrandList(ref errors); List <BrandInfo> BrandList2 = DALBrand.ReadBrandList(ref errors); Assert.AreEqual(BrandList1.Count, BrandList2.Count); Assert.AreEqual(errors.Count, 0); for (int i = 0; i < BrandList1.Count; i++) { Assert.AreEqual(BrandList1[i].brand_id, BrandList2[i].brand_id); Assert.AreEqual(BrandList1[i].brand_name, BrandList2[i].brand_name); } }
public void UpdateProductBrandTest() { int myId = 1; Random rand = new Random(); BrandInfo Brand = new BrandInfo(myId, "Sanrio " + rand.Next(10000)); List <string> errors = new List <string>(); int result = DALBrand.UpdateBrand(Brand.brand_id, Brand.brand_name, ref errors); Assert.AreEqual(0, errors.Count); Assert.AreNotEqual(-1, result); BrandInfo verifyBrand = DALBrand.ReadBrandDetail(myId, ref errors); Assert.AreEqual(0, errors.Count); Assert.AreEqual(Brand.brand_id, verifyBrand.brand_id); Assert.AreEqual(Brand.brand_name, verifyBrand.brand_name); }
public static int UpdatePV(ProductVariationInfo productVariation, ref List <string> errors) { if (productVariation == null) { errors.Add("Product Variation cannot be null"); } else if (productVariation.product_variation_id <= 0 || productVariation.product_variation_id > DALProductVariationInfo.ReadPVList(ref errors).Count) { errors.Add("Invalid product variation id"); } else if (productVariation.product_id <= 0 || productVariation.product_id > DALProduct.ReadProductList(ref errors).Count) { errors.Add("Invalid product_id"); } else if (productVariation.product_brand_id <= 0 || productVariation.product_brand_id > DALBrand.ReadBrandList(ref errors).Count) { errors.Add("Invalid product_brand_d"); } else if (productVariation.product_cutting_id <= 0 || productVariation.product_cutting_id > DALProductCutting.ReadProductCuttingList(ref errors).Count) { errors.Add("Invalid product_cutting_id"); } else if (productVariation.product_color_id <= 0 || productVariation.product_color_id > DALProductColor.ReadProductColorList(ref errors).Count) { errors.Add("Invalid product_color_id"); } else if (productVariation.sex != 'F' && productVariation.sex != 'M' && productVariation.sex != 'U') { errors.Add("Invalid sex"); } else if (productVariation.size != "XS" && productVariation.size != "S" && productVariation.size != "M" && productVariation.size != "L" && productVariation.size != "XL" && productVariation.size != "XXL") { errors.Add("Invalid size"); } else if (productVariation.stock < 0) { errors.Add("Invalid stock"); } else if (productVariation.price < 0) { errors.Add("Invalid price"); } else if (productVariation.condition != 'a' && productVariation.condition != 's' && productVariation.condition != 'd') { errors.Add("Invalid condition"); } if (errors.Count > 0) { return(-1); } return(DALProductVariationInfo.UpdateProductVariationInfo(productVariation, ref errors)); }
public static int CreatePV(ProductVariationInfo productVariation, ref List <string> errors) { if (productVariation == null) { errors.Add("Product Variation cannot be null"); return(-1); } System.Diagnostics.Debug.WriteLine("THIS IS THE PID:" + productVariation.product_id); if (productVariation.product_id <= 0 || productVariation.product_id > DALProduct.ReadProductList(ref errors).Count) { errors.Add("Invalid product_id"); } if (productVariation.product_brand_id <= 0 || productVariation.product_brand_id > DALBrand.ReadBrandList(ref errors).Count) { errors.Add("Invalid product_brand_id"); } if (productVariation.product_cutting_id <= 0 || productVariation.product_cutting_id > DALProductCutting.ReadProductCuttingList(ref errors).Count) { errors.Add("Invalid product_cutting_id"); } if (productVariation.product_color_id <= 0 || productVariation.product_color_id > DALProductColor.ReadProductColorList(ref errors).Count) { errors.Add("Invalid product_color_id"); } if (productVariation.sex != 'F' && productVariation.sex != 'M' && productVariation.sex != 'U') { errors.Add("Invalid sex"); } if (productVariation.size != "XS" && productVariation.size != "S" && productVariation.size != "M" && productVariation.size != "L" && productVariation.size != "XL" && productVariation.size != "XXL") { errors.Add("Invalid size"); } if (productVariation.stock < 0) { errors.Add("Invalid stock"); } if (productVariation.price < 0) { errors.Add("Invalid price"); } if (productVariation.condition != 'a' && productVariation.condition != 's' && productVariation.condition != 'd') { errors.Add("Invalid condition"); } if (errors.Count > 0) { return(-1); } return(DALProductVariationInfo.CreatePV(productVariation, ref errors)); }
public static List <BrandInfo> ReadAllBrand(ref List <string> errors) { return(DALBrand.ReadBrandList(ref errors)); }