Beispiel #1
0
        public async Task <IActionResult> Search(AppUserSearchModel appUserSearchModel)
        {
            ViewBag.AppUserSearchModel = appUserSearchModel;

            ViewBag.AppUserStatuses = _selectListRepository.GetSelectListAppUserStatuses(appUserSearchModel.AppUserStatusId ?? 0);

            var query = userProfileRepository.FindAppUsers(appUserSearchModel);

            if (appUserSearchModel.IsRequestDataImmediately)
            {
                var appUsers = await query.ToListAsync();

                var rolesDictionary = new Dictionary <string, List <string> >();
                foreach (var appUser in appUsers)
                {
                    var appUserRoles = await userManager.GetRolesAsync(appUser);

                    if (appUserRoles.Count > 0)
                    {
                        rolesDictionary.Add(appUser.Id, appUserRoles.ToList());
                    }
                }
                ViewBag.RolesDictionary = rolesDictionary;
                return(View(appUsers));
            }
            else
            {
                return(View(new List <AppUser>()));
            }
        }