public async Task <ActionResult> UpdateRoleMenu(string MenuID, string RoleIDs) { try { if (MenuID != null && RoleIDs != null) { string[] roleid = RoleIDs.Split(','); int intMenuID = Convert.ToInt32(MenuID); List <RoleMenu> lrm = new List <RoleMenu>(); foreach (var item in roleid) { int intRoleID = Convert.ToInt32(item); bool IsExist = await RoleMenuRepository.ExistAsync(ur => ur.RoleID == intRoleID && ur.MenuID == intMenuID); if (!IsExist) { RoleMenu rm = new RoleMenu(); rm.RoleID = intRoleID; rm.MenuID = intMenuID; lrm.Add(rm); } await UpdateChild(lrm, intMenuID, intRoleID); } RoleMenuRepository.AddRange(lrm); return(Json(new { Success = true })); } return(Json(new { Success = false })); } catch (Exception ex) { LogRepository.Add(new EventLog() { Name = Session["LoginedUser"].ToString(), Date = DateTime.Now.ToLocalTime(), Event = "更新RoleMenu失败" + ex.Message }); return(Json(new { Success = false })); } }