public IActionResult EditUser(Guid?id, string returnUrl = null) { ViewBag.ReturnUrl = Url.IsLocalUrl(returnUrl) ? returnUrl : Url.RouteUrl("userIndex"); ViewBag.SysRoleList = _sysRoleService.GetAllRoles().Select(o => new SelectListItem() { Value = o.Id.ToString(), Text = o.Name }).ToList(); if (id != null) { var model = _sysUserService.GetById(id.Value); if (model == null) { return(Redirect(ViewBag.ReturnUrl)); } var sysUserRole = _sysUserRoleService.GetAll().FirstOrDefault(o => o.UserId == id); if (!model.IsAdmin) { ViewBag.SysRoleList = _sysRoleService.GetAllRoles().Select(o => new SelectListItem() { Value = o.Id.ToString(), Text = o.Name, Selected = (o.Id == sysUserRole.RoleId) }).ToList(); } return(View(model)); } return(View()); }
public List <SysRole> GetAllRoles() { return(_sysRoleService.GetAllRoles()); }
public IActionResult Index() { return(View(_sysRoleService.GetAllRoles())); }