public JsonResult Delete(int id = 0) { BaseUser model = db.BaseUsers.Find(id); foreach (var item in model.BaseUserMenus.ToList()) { db.BaseUserMenus.Remove(item); } foreach (var item in model.BaseUserActions.ToList()) { db.BaseUserActions.Remove(item); } foreach (var item in model.BaseWidgets.ToList()) { db.BaseWidgets.Remove(item); } model.BaseProfiles.Clear(); db.BaseUsers.Remove(model); db.SaveChanges(); BoolString validation = model.AfterDelete(db); if (validation.BoolValue) { return(Json(new { Message = validation.StringValue })); } return(Json("ok", JsonRequestBehavior.AllowGet)); }