//添加修改角色 public IActionResult ModifyRole() { //展示页面 if (!Request.Method.ToUpper().Equals("POST", StringComparison.OrdinalIgnoreCase) || !Request.HasFormContentType) { // 权限和菜单 ModifyRoleModel model = new ModifyRoleModel(); var layoutModel = this.GetLayoutModel(); if (layoutModel != null) { layoutModel.ToT(ref model); } int id = 0; int.TryParse(Request.Query["id"], out id); if (id > 0) { model.PageTitle = "修改角色"; var role = CMSAdminBO.GetRoleByID(id); if (role != null && role.ID > 0) { model.Role = role; } } else { model.PageTitle = "添加角色"; } return(View(model)); } else { var msg = new Message(10, "修改失败!"); int id = 0; int.TryParse(Request.Form["id"], out id); string title = Request.Form["title"]; byte state = 1; byte.TryParse(Request.Form["state"], out state); var role = new Role() { ID = id, Title = title, State = state }; if (role.ID > 0) { msg = CMSAdminBO.UpdateRole(role); } else { msg = CMSAdminBO.CreateRole(role); } return(new JsonResult(msg)); } }