public ActionResult Edit([Bind(Include = "ID,ProductName,ShortDescription,ImageURL, FullDescription,UnitPrice,CategoryID")] Product product, HttpPostedFileBase image) { // is image passed? if (image != null) { uploadAzureBlobStorage(product, image); } // keep the current image else { Product productDB = db.Products.Find(product.ID); product.ImageURL = productDB.ImageURL; db.Entry(productDB).State = EntityState.Detached; } if (ModelState.IsValid) { db.Entry(product).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.CategoryID = new SelectList(db.Categories, "ID", "CategoryName", product.CategoryID); return(View(product)); }
public ActionResult Edit([Bind(Include = "ID,CategoryName,Description")] Category category) { if (ModelState.IsValid) { db.Entry(category).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(category)); }
public void Edit(Employee employee) { if (employee is null) { throw new ArgumentException(nameof(employee)); } _dbContext.Attach(employee); _dbContext.Entry(employee).State = EntityState.Modified; }
public virtual void Update(T entity) { dbSet.Attach(entity); dataContext.Entry(entity).State = EntityState.Modified; }