public void Remove(Product p) { int index = Search(p.ID); if (index != -1) { Products.RemoveAt(index); } }
public bool Add(Product p) { int index = Search(p.ID); if (index == -1) { Products.Add(p); return true; } return false; }
protected void btnSave_Click(object sender, EventArgs e) { Product p = new Product(); p.Name = txtName.Text; p.Price = ToSQL.SQLToDecimal(txtPriceNew.Text); p.ProductType_ID = ToSQL.SQLToIntNull(ddlProductType.SelectedValue); p.Manufacuturer_ID = ToSQL.SQLToIntNull(ddlManufacturer.SelectedValue); p.Description = CKEditorControlDescription.Text; p.IsActive = true; p.IsBestSelling = chkBestSelling.Checked; p.IsNew = chkNew.Checked; p.IsSpecial = chkSpecial.Checked; p.DateCreated = DateTime.Now; if (fulImageDefault.HasFile) { ProductImage image = new ProductImage(); string url = CheckFileShared.UploadAndRsizeImage(fulImageDefault.PostedFile); if (url != "") { image.Image = url; image.IsDefault = true; p.ProductImages.Add(image); } } HttpFileCollection uploads = Request.Files; //for (int fileCount = 0; fileCount < uploads.Count; fileCount++) foreach (HttpPostedFile uploadedFile in FileUploadJquery.PostedFiles) { ProductImage image = new ProductImage(); string url = CheckFileShared.UploadAndRsizeImage(uploadedFile); if (url != "") { image.Image = url; image.IsDefault = false; p.ProductImages.Add(image); } } if (productRepo.CreateProduct(p) > 0) { ProductPriceHistory productPriceHistory = new ProductPriceHistory(); productPriceHistory.Product_ID = p.ID; productPriceHistory.Price = p.Price; productPriceHistory.DateCreated = DateTime.Now; new ProductPriceHistoryRepo().CreateProductPriceHistory(productPriceHistory); Response.Redirect("~/Admincp/Management-Products.aspx"); } else { lbMessage.Text = "Please check input data! Try again!"; } }
public Cart ConverProductToCart(Product product) { this.ProductID = product.ID; this.ProductName = product.Name; this.Price = product.Price; return this; }