[HttpPost] [ValidateAntiForgeryToken] public ActionResult Modify(Role role) { if (ModelState.IsValid) { var _resp = roleManager.Update(role); if (_resp.Code == 1) return View("Prompt", new Prompt() { Title = "修改角色成功", Message = "你已成功修改了角色【" + role.Name + "】", Buttons = new List<string>() { "<a href=https://www.jb51.net/article/\"" + Url.Action("Index", "Role") + "https://www.jb51.net/article/\" class=https://www.jb51.net/article/\"btn btn-default\">角色管理</a>", "<a href=https://www.jb51.net/article/\"" + Url.Action("Modify", "Role", new { id = role.RoleID }) + "https://www.jb51.net/article/\" class=https://www.jb51.net/article/\"btn btn-default\">查看</a>", "<a href=https://www.jb51.net/article/\"" + Url.Action("Add", "Role") + "https://www.jb51.net/article/\" class=https://www.jb51.net/article/\"btn btn-default\">添加</a>" } }); else return View("Prompt", new Prompt() { Title = "修改角色失败", Message = "失败原因:"+ _resp.Message, Buttons = new List<string>() { "<a href=https://www.jb51.net/article/\"" + Url.Action("Index", "Role") + "https://www.jb51.net/article/\" class=https://www.jb51.net/article/\"btn btn-default\">角色管理</a>", "<a href=https://www.jb51.net/article/\"" + Url.Action("Modify", "Role", new { id = role.RoleID }) + "https://www.jb51.net/article/\" class=https://www.jb51.net/article/\"btn btn-default\">返回</a>"} }); } else return View(role); }
6、删除角色
在控制器中添加Modify方法。
/// <summary> /// 删除【Json】 /// </summary> /// <param>RoleID</param> /// <returns></returns> [HttpPost] public JsonResult DeleteJson(int id) { return Json(roleManager.Delete(id)); }
角色功能完成,按F5浏览器中预览效果
---------------------------------------------------------------------------------------
代码见:https://ninesky.codeplex.com/SourceControl/latest
代码下载:https://ninesky.codeplex.com 点击SOURCE CODE 点击Download下载源文件。