Exemplo n.º 1
0
        public MembershipUser CreateMembershipUser(string username, string password, string email, bool isApproved)
        {
            Account account = new Account();

            account.Username     = username;
            account.Email        = email;
            account.PasswordSalt = _crypt.CreateSalt();
            account.Password     = _crypt.CreatePasswordHash(password, account.PasswordSalt);
            account.CreatedDate  = DateTime.Now;

            if (!isApproved)
            {
                account.IsActivated = false;
                account.NewEmailKey = GenerateKey();
            }
            else
            {
                account.IsActivated = true;
            }

            account.IsLockedOut       = false;
            account.LastLockedOutDate = DateTime.Now;
            account.LastLoginDate     = DateTime.Now;
            account.LastModifiedDate  = DateTime.Now;

            account.DateBirthday = DateTime.Now;

            _db.AddToAccounts(account);
            _db.SaveChanges();

            if (!isApproved)
            {
                string ActivationLink = ConfigurationManager.AppSettings.Get("base_application_url") + "Account/Activate/" + account.Username + "/" + account.NewEmailKey;

                _notifyService.SendMessage(account.Email, "Actiovate your account!", _messageGenerator.MessageActivateAccount(account.Username, ActivationLink));
            }

            return(GetMembershipUser(username));
        }