public async Task <IActionResult> Confirm(int?id)
        {
            if (!ModelState.IsValid)
            {
                return(RedirectToAction(MethodNames.USR_UNVERIFIED));
            }

            if (id == null)
            {
                return(StatusCode((int)HttpStatusCode.BadRequest));
            }

            var found = _userRepository.Find(x => x.UserId == id).FirstOrDefault();

            if (found == null)
            {
                return(StatusCode((int)HttpStatusCode.NotFound));
            }


            await _userManager.AddToRoleAsync(found, RoleNames.ROLE_MEMBER);

            await _userManager.UpdateAsync(found);

            found.Verified = true;

            _userRepository.CommitChanges();

            await _eMailSender.SendUserConfirmationEmail(found.Email);

            return(RedirectToAction(MethodNames.USR_UNVERIFIED));
        }
        public async Task <IActionResult> Register(RegisterViewModel viewModel)
        {
            if (ModelState.IsValid)
            {
                var user = new User()
                {
                    UserName   = viewModel.Username,
                    Registered = DateTime.Now,
                    Email      = viewModel.Mail
                };

                var result = await _userManager.CreateAsync(user, viewModel.Password);

                if (result.Succeeded)
                {
                    await _userManager.UpdateAsync(user);

                    var admins = await _userManager.GetUsersInRoleAsync(RoleNames.ROLE_ADMIN);

                    foreach (var admin in admins)
                    {
                        var config = _notificationConfigurationRepository.GetConfigurationForUser(admin.UserId);
                        if (config != null && config.NewUserRegistered)
                        {
                            await _eMailSender.SendUserConfirmationEmail(admin.Email);
                        }
                    }

                    return(RedirectToAction(MethodNames.ACC_REGISTERED));
                }
                else
                {
                    ModelState.AddModelError("err_register", _localizer[AccountStrings.ACC_ERR_DUPLICATE_REGISTRATION]);
                }
            }
            return(View(viewModel));
        }