public void Delete(int id) { // delete içerisine bir id geldiğinde resim silecek tbl_productImage img = _context.tbl_productImage.Find(id); if (img != null) { _context.tbl_productImage.Remove(img); _context.SaveChanges(); } }
public ActionResult Edit(tbl_product product, IEnumerable <HttpPostedFileBase> image1) { if (product != null) { repository.Update(product); } if (image1.First() != null) { tbl_productImage newImg = new tbl_productImage(); newImg.productId = product.productId; foreach (var item in image1) { using (var br = new BinaryReader(item.InputStream)) { var data = br.ReadBytes(item.ContentLength); newImg.image = data; } repository.Save(newImg); } } return(RedirectToAction("Index")); }
public void Save(tbl_productImage model) { _context.tbl_productImage.Add(model); _context.SaveChanges(); }