Пример #1
0
        public IActionResult Index()
        {
            var vm = new UserManagementIndexViewModel {
                Users = _dbContext.Users.OrderBy(u => u.Email).Include(u => u.Roles).ToList()
            };

            return(View(vm));
        }
Пример #2
0
        public IActionResult Index()
        {
            var viewModel = new UserManagementIndexViewModel
            {
                Users = _context.Users.OrderBy(u => u.Name).ToList()
            };

            return(View(viewModel));
        }
        public IActionResult Index()
        {
            var vm = new UserManagementIndexViewModel
            {
                Users = _dbContext.Users.OrderBy(user => user.FirstName).ThenBy(user => user.LastName).ToList()
            };

            return(View(vm));
        }
Пример #4
0
        public IActionResult Index()
        {
            var vm = new UserManagementIndexViewModel
            {
                Users = _db.ApplicationUsers.OrderBy(u => u.ProfileName).Include(u => u.Roles).ToList()
            };

            return(View(vm));
        }
Пример #5
0
        public async Task <IActionResult> Index()
        {
            List <Author> authorList = null;
            var           vm         = new UserManagementIndexViewModel();

            vm.Users = _dbContext.Users.OrderBy(u => u.Email).Include(u => u.Roles).ToList();
            List <ApplicationUser> UserList = new List <ApplicationUser>();

            var user = await _userManager.GetUserAsync(User);

            long currentUserNode = (await _CBIBContext.Author.FindAsync(user.AuthorID)).NodeID;

            if (User.IsInRole("Global Administrator"))
            {
                vm.Users = _dbContext.Users.OrderBy(u => u.Email).Include(u => u.Roles).ToList();
            }

            else if (User.IsInRole("Node Administrator"))
            {
                authorList = _CBIBContext.Author.ToList();
                List <Author>          list  = new List <Author>();
                List <ApplicationUser> Users = new List <ApplicationUser>();

                foreach (Author a in authorList)
                {
                    if (a.NodeID == currentUserNode)
                    {
                        list.Add(a);
                    }
                }

                UserList = await _dbContext.Users.Include(r => r.Roles).ToListAsync();

                foreach (ApplicationUser u in UserList.ToList())
                {
                    foreach (Author a in list)
                    {
                        if (u.AuthorID == a.AuthorID)
                        {
                            Users.Add(u);
                        }
                    }
                }
                vm.Users = Users;
            }
            return(View(vm));
        }
Пример #6
0
        public IActionResult Index()
        {
            //var users = _context.AspNetUsers
            //  .Join(_context.ResearchTeamMembers, anu => anu.Email, rtm => rtm.Email, (anu, rtm) => new { anu, rtm })
            //  .DefaultIfEmpty()
            //  .Select(x => new User
            //  {
            //    Email = x.anu.Email,
            //    Roles = string.Join(", ", _context.AspNetUserRoles
            //      .Where(y => y.UserId == x.anu.Id)
            //      .Join(_context.AspNetRoles, anur => anur.RoleId, anr => anr.Id, (anur, anr) => anr.Name)
            //      .Select(z => z)),
            //    FirstName = x.rtm.FirstName,
            //    LastName = x.rtm.LastName
            //  });

            var users = _context.AspNetUsers
                        .GroupJoin(
                _context.ResearchTeamMembers,
                anu => anu.Email,
                rtm => rtm.Email,
                (anu, rtm) => new { anu, rtm })
                        .SelectMany(
                x => x.rtm.DefaultIfEmpty(),
                (x, y) => new User
            {
                FirstName = y.FirstName,
                LastName  = y.LastName,
                Email     = x.anu.Email,
                Active    = y.Active == "Y",
                Roles     = string.Join(", ", _context.AspNetUserRoles
                                        .Where(z => z.UserId == x.anu.Id)
                                        .Join(_context.AspNetRoles, anur => anur.RoleId, anr => anr.Id, (anur, anr) => anr.Name)
                                        .Select(z => z))
            })
                        .OrderBy(x => x.FirstName)
                        .ThenBy(x => x.LastName);

            var vm = new UserManagementIndexViewModel
            {
                Users = users.ToList()
            };

            return(View(vm));
        }