public MembershipUser CreateUser(User newUser)
        {
            newUser.Password = EncodePassword(newUser.Password);
            newUser.CreationDate = DateTime.Now;
            newUser.LastActivity = DateTime.Now;
            newUser.LastPasswordChangedDate = DateTime.Now;
            newUser.LastLoginDate = DateTime.Now;
            newUser.LastLockedOutDate = DateTime.MaxValue;

            try
            {
                _userRepository.Add(newUser);
                _userRepository.Persist();
                return newUser.ToMembershipUser();
            }
            catch (Exception e)
            {
                throw new Exception(e.Message, e);
            }
        }
 public MembershipUser CreateUser(string userName, string password, string email)
 {
     var newUser = new User
                       {
                           UserName = userName,
                           Email = email,
                           Password = EncodePassword(password),
                           CreationDate = DateTime.Now,
                           LastActivity = DateTime.Now,
                           LastPasswordChangedDate = DateTime.Now,
                           LastLoginDate = DateTime.Now,
                           LastLockedOutDate = DateTime.MaxValue
                       };
     try
     {
         _userRepository.Add(newUser);
         _userRepository.Persist();
         return newUser.ToMembershipUser();
     }
     catch (Exception e)
     {
         throw new Exception(e.Message, e);
     }
 }
        /// <summary>
        /// Adds a new membership user to the data source. 
        /// </summary>
        /// <param name="username"></param>
        /// <param name="password"></param>
        /// <param name="email"></param>
        /// <param name="passwordQuestion"></param>
        /// <param name="passwordAnswer"></param>
        /// <param name="isApproved"></param>
        /// <param name="providerUserKey"></param>
        /// <param name="status"></param>
        /// <returns></returns>
        public override MembershipUser CreateUser(string username, string password, string email, string passwordQuestion, string passwordAnswer, bool isApproved, object providerUserKey, out MembershipCreateStatus status)
        {             
            //TODO: All code shall be moved into the application service.
            User newUser = new User();

            newUser.UserName = username;
            newUser.Password = password;
            newUser.Email = email;
            newUser.CreationDate = DateTime.Now;
            newUser.LastActivity = DateTime.Now;
            newUser.LastLockedOutDate = DateTime.Now;
            newUser.LastLoginDate = DateTime.Now;
            newUser.LastPasswordChangedDate = DateTime.Now;
                

            if (_membershipProviderApplicationService.GetUser(newUser.UserName, false, ProviderName) != null)
            {
                status = MembershipCreateStatus.DuplicateUserName;
            }
            else if (_membershipProviderApplicationService.GetUserByMail(newUser.Email, ProviderName) != null)
            {
                status = MembershipCreateStatus.DuplicateEmail;
            }
            else
            {
                try
                {
                    _membershipProviderApplicationService.CreateUser(newUser);
                    status = MembershipCreateStatus.Success;
                    return newUser.ToMembershipUser();
                }
                catch(Exception e)
                {
                    status = MembershipCreateStatus.UserRejected;
                    throw new Exception(e.Message,e);
                }
            }
                      

            return null;
        }