Exemplo n.º 1
0
        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();
            }
        }
Exemplo n.º 2
0
        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"));
        }
Exemplo n.º 3
0
 public void Save(tbl_productImage model)
 {
     _context.tbl_productImage.Add(model);
     _context.SaveChanges();
 }