Beispiel #1
0
        public async Task <IActionResult> Index()
        {
            // Get all users
            List <GolfioUser> golfioUsers = await _golfioUser.GetAllUsersAsync();

            // Convert each user to Admin Index View Model
            // Get all claims for each user
            List <AdminIndexViewModel> adminIndexViewModels = new List <AdminIndexViewModel>();

            foreach (GolfioUser golfioUser in golfioUsers)
            {
                AdminIndexViewModel adminIndexViewModel = new AdminIndexViewModel
                {
                    Id       = golfioUser.Id,
                    FullName = golfioUser.FullName,
                    Claims   = await _golfioUser.GetUserClaimsAsync(golfioUser),
                };

                adminIndexViewModels.Add(adminIndexViewModel);
            }
            ;

            // Sort by user name
            adminIndexViewModels.OrderBy(adminIndexVM => adminIndexVM.FullName);

            return(View(adminIndexViewModels));
        }
Beispiel #2
0
        public async Task <IActionResult> Edit()
        {
            UserEditViewModel userEditVM = new UserEditViewModel();
            List <string>     claimTypes = new List <string>();

            string userId = User.FindFirstValue(ClaimTypes.NameIdentifier);

            userEditVM.GolfioUser = await _golfioUser.GetUserAsync(userId);

            (await _golfioUser.GetUserClaimsAsync(userEditVM.GolfioUser))
            .ForEach(uc => claimTypes.Add(uc.Type.ToString()));

            userEditVM.UserClaims = string.Join(", ", claimTypes);

            return(View(userEditVM));
        }