Example #1
0
        public int RegisterUser(AccountInfoDto newUser, string registrationUrlPrefix)
        {
            using (var uow = UnitOfWorkProvider.Create())
            {
                var userManager = AppUserManager();
                var user = userManager.FindByName(newUser.UserName);

                if (user != null)
                {
                    throw new UIException("Užívateľ s týmo nickom už existuje.");
                }

                if (userManager.FindByEmail(newUser.Email) != null)
                {
                    throw new UIException("Užívateľ s týmo mailom už existuje.");
                }
                // create the user
                user = new User()
                {
                    Email = newUser.Email,
                    UserName = newUser.UserName,
                };

                userManager.Create(user);

                uow.Commit();

                // send registration e-mail
                var registrationUrl = registrationUrlPrefix + "?username="******"&token=" + userManager.GeneratePasswordResetToken(user.Id);
                MailerService.SendNewAccountEmail(newUser.Email, registrationUrl);

                return user.Id;
            }
        }
Example #2
0
 public void UpdateUserInfo(int currentUserId, AccountInfoDto userInfo)
 {
     using (var uow = UnitOfWorkProvider.Create())
     {
         var userManager = AppUserManager();
         var user = userManager.FindById(currentUserId);
         Mapper.Map(userInfo, user);
         uow.Commit();
     }
 }