public IHttpActionResult Delete(int id) { var productdel = p.ProductDetails.Where(x => x.ID == id).FirstOrDefault(); p.Entry(productdel).State = System.Data.Entity.EntityState.Deleted; p.SaveChanges(); return(Ok()); }
public ActionResult Edit([Bind(Include = "Id,Name,EmailID,Password")] user_master user_master) { if (ModelState.IsValid) { db.Entry(user_master).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(user_master)); }
public ActionResult Edit([Bind(Include = "ItemId,CategoryId,ItemCode,ItemName,ShortDescription,LongDescription,SmallImagePath,LongImagePath,ItemPrice")] Item item) { if (ModelState.IsValid) { db.Entry(item).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(item)); }
public async Task <bool> UpdateProductAsync(int id, Product product) { var eProduct = await _context.Products.FirstOrDefaultAsync(p => p.Id == id); if (eProduct == null) { return(false); } eProduct.ProductName = product.ProductName; eProduct.ProductUrl = product.ProductUrl; eProduct.ProductCode = product.ProductCode; try { _context.Entry(eProduct).State = EntityState.Modified; await _context.SaveChangesAsync(); return(true); } catch (Exception ex) { string errorMessage = ex.Message + ex.StackTrace + ex.InnerException; return(false); } }