public List <ProductTopping> SelectProductToppingByIdCatAndName(int idCat, string keyword) { List <ProductTopping> products = new List <ProductTopping>(); MySqlConnection con = new MySqlConnection(strCon); con.Open(); string strCmd = "SELECT * FROM Product WHERE idCat=@idCat AND nameProduct LIKE '%" + keyword + "%'"; MySqlCommand cmd = new MySqlCommand(strCmd, con); cmd.Parameters.Add(new MySqlParameter("@idCat", idCat)); MySqlDataReader dr = cmd.ExecuteReader(); while (dr.Read()) { ProductTopping pro = new ProductTopping(); pro.IdProduct = (int)dr["idProduct"]; pro.IdCat = (int)dr["idCat"]; pro.NameProduct = (string)dr["nameProduct"]; pro.PriceLargeProduct = (dr.IsDBNull(dr.GetOrdinal("priceLargeProduct"))) ? 0 : (int?)dr["priceLargeProduct"]; pro.PriceMediumProduct = (dr.IsDBNull(dr.GetOrdinal("priceMediumProduct"))) ? 0 : (int?)dr["priceMediumProduct"]; pro.PriceSmallProduct = (dr.IsDBNull(dr.GetOrdinal("priceSmallProduct"))) ? 0 : (int?)dr["priceSmallProduct"]; pro.PriceProduct = (dr.IsDBNull(dr.GetOrdinal("priceProduct"))) ? 0 : (int?)dr["priceProduct"]; pro.DescriptionProduct = (dr.IsDBNull(dr.GetOrdinal("descriptionProduct"))) ? "Không có mô tả" : (string)dr["descriptionProduct"]; pro.imgProduct = (dr.IsDBNull(dr.GetOrdinal("imgProduct"))) ? "Không có hình" : (string)dr["imgProduct"]; pro.rating = (int)dr["rate"]; List <Topping> top = SelectToppingByIdProduct((int)dr["idProduct"]); pro.Topping = top; products.Add(pro); } con.Close(); return(products); }
public ProductTopping AddProductTopping(int vProductToppingID, int vProductID, int vToppingID, decimal vExtraPrice, decimal vIncrement, string vTitle, DateTime vAddedDate, string vAddedBy, DateTime vUpdatedDate, string vUpdatedBy, bool vActive) { ProductTopping lProductTopping = new ProductTopping(); using (FRShoppingEntities frctx = new FRShoppingEntities()) { if (vProductToppingID > 0) { lProductTopping = frctx.ProductToppings.FirstOrDefault(u => u.ProductToppingId == vProductToppingID); lProductTopping.ExtraToppingPrice = vExtraPrice; lProductTopping.Increment = vIncrement; lProductTopping.UpdatedDate = vUpdatedDate; lProductTopping.UpdatedBy = vUpdatedBy; lProductTopping.Active = vActive; return(frctx.SaveChanges() > 0 ? lProductTopping : null); } else { lProductTopping.ExtraToppingPrice = vExtraPrice; lProductTopping.Increment = vIncrement; lProductTopping.ToppingTitle = vTitle; lProductTopping.ProductId = vProductID; lProductTopping.ToppingId = vToppingID; lProductTopping.AddedDate = vAddedDate; lProductTopping.AddedBy = vAddedBy; lProductTopping.UpdatedDate = vUpdatedDate; lProductTopping.UpdatedBy = vUpdatedBy; lProductTopping.Active = vActive; return(AddProductTopping(lProductTopping)); } } }
private bool ChangeLockState(ProductTopping vProductTopping, bool vState) { using (FRShoppingEntities frenty = new FRShoppingEntities()) { ProductTopping up = frenty.ProductToppings.FirstOrDefault(e => e.ProductToppingId == vProductTopping.ProductToppingId); up.UpdatedDate = DateTime.Now; up.Active = vState; return(frenty.SaveChanges() > 0 ? true : false); } }
public ProductTopping AddProductTopping(ProductTopping vProductTopping) { try { Shoppingctx.ProductToppings.Add(vProductTopping); base.PurgeCacheItems(CacheKey); return(Shoppingctx.SaveChanges() > 0 ? vProductTopping : null); } catch (Exception ex) { return(null); } }
public ProductTopping UpdateProductTopping(ProductTopping vProductTopping) { throw new NotImplementedException(); }
public bool UnDeleteProductTopping(ProductTopping vProductTopping) { throw new NotImplementedException(); }
public bool UnlockProductTopping(ProductTopping vProductTopping) { return(ChangeLockState(vProductTopping, true)); }
public bool LockProductTopping(ProductTopping vProductTopping) { return(ChangeLockState(vProductTopping, false)); }