public ActionResult EditRoles(EditUserRolesViewModel model) { Message msg = new Message(); string userRoles = Request.Form["UserRoles"]; try { msg = CMSService.UpdateFieldOneByOne("User", "CMSUser", "UserId=" + model.UserId, "UserRoles", userRoles); return RedirectToAction("Index"); } catch { msg.MessageStatus = "Error"; msg.MessageInfo = "操作出错了"; ViewBag.Status = msg.MessageStatus; ViewBag.msg = msg.MessageInfo; return View(); } }
// 编辑权限 public ActionResult EditRoles(int id) { EditUserRolesViewModel model = new EditUserRolesViewModel(); DataTable dt = CMSService.SelectOne("User", "CMSUser", "UserId=" + id); foreach (DataRow dr in dt.Rows) { UserDto dto = new UserDto(); dto = UserMapping.getDTO(dr); model.UserId = dto.UserId; model.UserName = dto.UserName; model.UserRoles = dto.UserRoles; } DataTable RoleDt = CMSService.SelectSome("Role", "CMSRole", "1=1"); List<RoleDto> ListRoles = new List<RoleDto>(); foreach (DataRow dr in RoleDt.Rows) { RoleDto roleDto = RoleMapping.getDTO(dr); ListRoles.Add(roleDto); } ViewData["ListRoles"] = ListRoles; return View(model); }