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