Beispiel #1
0
        // GET: UserRole
        public ActionResult Index(int?id)
        {
            var viewModel = new UserRoleIndexData();

            //var SysUsers = db.SysUsers.Include();
            viewModel.SysUsers = db.SysUsers.Include(u => u.SysDepartment).Include(u => u.SysUserRoles.Select(ur => ur.SysRole)).OrderBy(u => u.UserName);

            if (id != null)
            {
                ViewBag.UserID       = id.Value;
                ViewBag.SysUserRoles = (viewModel.SysUserRoles.Where(u => u.SysUserID == id.Value)).Select(ur => ur.SysRole);
            }
            return(View(viewModel));
        }
Beispiel #2
0
        //
        // GET: /UserRole/
        public ActionResult Index(int?ID)
        {
            var viewModel = new UserRoleIndexData();

            viewModel.SysUsers = db.SysUsers.Include(u => u.SysDepartment)
                                 .Include(u => u.SysUserRoles.Select(ur => ur.SysRole))
                                 .OrderBy(u => u.UserName);

            if (ID != null)
            {
                ViewBag.UserID         = ID.Value;
                viewModel.SysUserRoles = viewModel.SysUsers.Where(u => u.ID == ID.Value).Single().SysUserRoles;
                viewModel.SysRoles     = (viewModel.SysUserRoles.Where(ur => ur.SysUserID == ID.Value)).Select(ur => ur.SysRole);
            }
            return(View(viewModel));
        }