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