public ActionResult Creat(Address address) { if (ModelState.IsValid) { dbContext.Addresses.Add(address); dbContext.SaveChanges(); int index = 0; index = dbContext.Addresses.OrderBy(x => x.Name).ToList().IndexOf(address); return Json(index, JsonRequestBehavior.AllowGet); } return new HttpStatusCodeResult(400, "Custom Error Message 3"); }
public ActionResult UpdateAddress(Address address) { if (ModelState.IsValid) { dbContext.Entry(address).State = EntityState.Modified; dbContext.SaveChanges(); return null; } else { return new HttpStatusCodeResult(400, "Custom Error Message 2"); } }