예제 #1
0
 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());
 }
예제 #2
0
 public List <SysRole> GetAllRoles()
 {
     return(_sysRoleService.GetAllRoles());
 }
예제 #3
0
 public IActionResult Index()
 {
     return(View(_sysRoleService.GetAllRoles()));
 }