Пример #1
0
        public async Task <IActionResult> Index()
        {
            var user = await _rcmUserManager.GetUserAsync(_httpContextAccessor.HttpContext.User);

            var viewModel = new ManageViewModel()
            {
                ConfirmedEmail     = await _rcmUserManager.IsEmailConfirmedAsync(user),
                TwoFactorActivated = await _rcmUserManager.GetTwoFactorEnabledAsync(user),
                Roles = await _rcmUserManager.GetRolesAsync(user)
            };

            return(View(viewModel));
        }
Пример #2
0
        public async Task <IViewComponentResult> InvokeAsync()
        {
            if (_httpContextAccessor.HttpContext.User.Identity.IsAuthenticated)
            {
                var user = await _rcmUserManager.GetUserAsync(_httpContextAccessor.HttpContext.User);

                return(View(user));
            }

            return(View("NotLogged"));
        }
Пример #3
0
        public async Task <IActionResult> Edit(ProfileViewModel profileViewModel)
        {
            if (!ModelState.IsValid)
            {
                NotifyModelStateErrors();
                return(View(profileViewModel));
            }

            var user = await _rcmUserManager.GetUserAsync(_httpContextAccessor.HttpContext.User);

            var result = await _rcmUserManager.ChangeBasicInfoAsync(user, profileViewModel.FirstName, profileViewModel.LastName, profileViewModel.Age);

            if (result.Succeeded)
            {
                NotifyCommandResultSuccess();
                return(RedirectToAction(nameof(Index)));
            }
            else
            {
                result.Errors.ToList().ForEach(e => NotifyIdentityError(e.Description));
            }

            return(View(profileViewModel));
        }
Пример #4
0
        public async Task <IActionResult> Update(EmpresaViewModel empresa)
        {
            if (!ModelState.IsValid)
            {
                NotifyModelStateErrors();
                return(View(empresa));
            }

            var commandResult = await _empresaApplicationService.AddOrUpdate(empresa);

            if (commandResult.Success)
            {
                if (!_httpContextAccessor.HttpContext.User.HasClaim(c => c.Type == "ActiveCompany"))
                {
                    _user = await _rcmUserManager.GetUserAsync(_httpContextAccessor.HttpContext.User);

                    var result = await _rcmUserManager.AddClaimAsync(_user, new Claim("ActiveCompany", "True"));

                    if (result.Succeeded)
                    {
                        await _rcmSignInManager.RefreshSignInAsync(_user);
                    }
                    else
                    {
                        NotifyIdentityErrors(result);
                        return(View(empresa));
                    }
                }

                NotifyCommandResultSuccess();
                return(RedirectToAction(nameof(Details)));
            }
            else
            {
                NotifyCommandResultErrors(commandResult.Errors);
            }

            return(View(empresa));
        }
Пример #5
0
        public async Task <IActionResult> Index()
        {
            var currentUser = await _rcmUserManager.GetUserAsync(_httpContextAccessor.HttpContext.User);

            var users = new List <UserViewModel>();

            foreach (var user in _rcmUserManager.Users)
            {
                if (user == currentUser)
                {
                    continue;
                }

                users.Add(new UserViewModel()
                {
                    User  = user,
                    Roles = (List <string>) await _rcmUserManager.GetRolesAsync(user)
                });
            }

            return(View(users));
        }