Ejemplo n.º 1
0
        public void ConfirmNewUser(string userId, UserAndOrganizationDTO userAndOrg)
        {
            var applicationUser = _usersDbSet.First(user => user.Id == userId);

            _userAdministrationValidator.CheckIfEmploymentDateIsSet(applicationUser.EmploymentDate);

            var hasRole = _userManager.IsInRole(userId, Constants.Authorization.Roles.FirstLogin);

            _userAdministrationValidator.CheckIfUserHasFirstLoginRole(hasRole);

            var addRoleResult    = _userManager.AddToRole(userId, Constants.Authorization.Roles.User);
            var removeRoleResult = _userManager.RemoveFromRole(userId, Constants.Authorization.Roles.NewUser);

            _userAdministrationValidator.CheckForAddingRemovingRoleErrors(addRoleResult.Errors, removeRoleResult.Errors);
            _notificationService.SendConfirmedNotificationEmail(applicationUser.Email, userAndOrg);

            SetTutorialStatus(applicationUser, false);

            AddUserToMainWall(userId);
            _uow.SaveChanges(userAndOrg.UserId);
        }