public int Creat(Product product) { dbContext.Products.Add(product); dbContext.SaveChanges(); int index = 0; index = dbContext.Products.OrderBy(x => x.Name).ToList().IndexOf(product); return index; }
public ActionResult UpdateProduct(Product product) { if (ModelState.IsValid) { dbContext.Entry(product).State = EntityState.Modified; dbContext.SaveChanges(); return null; } else { return new HttpStatusCodeResult(400, "Custom Error Message 2"); } }