public override async Task <List <UserAdminViewModel> > HandleAsync(GetAdminsQuery query) { var admins = await _userManager.GetUsersInRoleAsync(Roles.Admin); var adminIds = admins.Select(u => u.Id).ToList(); var notAdmins = await ReadRepository.Set <ApplicationUser>().Where(u => !adminIds.Contains(u.Id)).ToListAsync(); var defaultAdmin = admins.First(a => a.Email == UserHelper.DefaultAdminEmail); admins.Remove(defaultAdmin); var viewModels = admins.Select(u => new UserAdminViewModel { IsAdmin = true, User = u }).ToList(); var notAdminViewModels = notAdmins.Select(u => new UserAdminViewModel { User = u }).ToList(); viewModels.AddRange(notAdminViewModels); return(viewModels.OrderBy(x => x.User.Id).ToList()); }
public async Task <IEnumerable <Admin> > Handle(GetAdminsQuery request, CancellationToken cancellationToken) { return(await _repository.GetAllAsync()); }