public ActionResult Index() { UserIndexViewModel vM = new UserIndexViewModel(); var isAdmin = _userRoleService.IsSuperAdmin(User.Identity.Name); if (isAdmin) { vM.UserApps = _userAppService.GetAllUserAppsDistinct(); } else { var appIds = _userAppService.GetAppIdsWhereAppRoleAdmin(User.Identity.Name); var userAppModelsWithOutAppCount = _userAppService.GetUserAppsForAppIds(appIds); var userAppModels = new List <UserAppModel>(); foreach (var item in userAppModelsWithOutAppCount) { item.AppCount = _userAppService.CountUserApps(item.BlazerId); userAppModels.Add(item); } vM.UserApps = userAppModels; } return(View(vM)); }