//[ValidateAntiForgeryToken] public ActionResult Create([Bind(Include = "MenuItem,Id,RoleName,MenuId,IsEnabled")] RoleMenu roleMenu) { if (ModelState.IsValid) { _roleMenuService.Insert(roleMenu); _unitOfWork.SaveChanges(); if (Request.IsAjaxRequest()) { return(Json(new { success = true }, JsonRequestBehavior.AllowGet)); } DisplaySuccessMessage("Has append a RoleMenu record"); return(RedirectToAction("Index")); } var menuitemRepository = _unitOfWork.Repository <MenuItem>(); ViewBag.MenuId = new SelectList(menuitemRepository.Queryable(), "Id", "Title", roleMenu.MenuId); if (Request.IsAjaxRequest()) { var modelStateErrors = String.Join("", this.ModelState.Keys.SelectMany(key => this.ModelState[key].Errors.Select(n => n.ErrorMessage))); return(Json(new { success = false, err = modelStateErrors }, JsonRequestBehavior.AllowGet)); } DisplayErrorMessage(); return(View(roleMenu)); }