public bool AddProduct(ProductModel product) { try { DL_Product dlProduct = new DL_Product(); dlProduct.AddProduct(product); } catch (Exception ex) { Console.WriteLine(ex.ToString()); return(false); } return(true); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { int productID = int.Parse(Request.QueryString["id"]); DL_Product productDL = new DL_Product(); DL_Store storeDL = new DL_Store(); ProductModel product = productDL.GetDetailProductWithId(productID); lblProductName.Text = product.ProductName; lblGiaBan.Text = product.Price; ddlSubStore.DataSource = ddlStore.DataSource = storeDL.GetData(); ddlStore.DataValueField = ddlSubStore.DataValueField = "store_id"; ddlStore.DataTextField = ddlSubStore.DataTextField = "store_name"; ddlSubStore.DataBind(); ddlStore.DataBind(); } }
public List <ProductModel> GetAllProducts() { try { DL_Product dlProduct = new DL_Product(); var productEntityList = dlProduct.GetAllProducts(); List <ProductModel> productModels = new List <ProductModel>(); foreach (var product in productEntityList) { productModels.Add(new ProductModel { ImagePath = product.ImagePath, Description = product.Description, Name = product.Name, Price = product.Price }); } return(productModels); } catch (Exception ex) { Console.WriteLine(ex.ToString()); return(null); } }