예제 #1
0
        public static string CreateUserAccount(MembershipProvider userMembershipProvider, User user)
        {
            string error = "";

            user.Email = user.Email.ToLower();

            User validateUser = UserService.GetUserByUsername(user.Username);
            if (validateUser.UserID > 0)
                return UserMessages.UsernameAlreadyUsed;

            validateUser = UserService.GetUserByEmail(user.Email);
            if (validateUser.UserID > 0)
                return UserMessages.EmailAlreadyUsed;

            MembershipCreateStatus status;
            MembershipUser mu = userMembershipProvider.CreateUser(user.Email, user.Password, user.Email, null, null, true, null, out status);

            if (status != MembershipCreateStatus.Success)
                return UserMessages.ErrorCreatingAccount;

            user.AspnetUserID = (Guid)mu.ProviderUserKey;

            int userID = CreateUserAccount(user);

            if(userID == 0)
            {
                // Delete user account
                userMembershipProvider.DeleteUser(user.Email, true);
                return UserMessages.ErrorCreatingAccount;
            }

            user.UserID = userID;

            return error;
        }
예제 #2
0
 private static int CreateUserAccount(User user)
 {
     int userID = UserData.CreateUser(user.AspnetUserID, user.Username, user.AccessType.GetHashCode(), user.Status, user.FirstName, user.LastName, user.Address1, user.Address2, user.City, user.State, user.Zip, user.Phone);
     return userID;
 }
예제 #3
0
 public static User ConvertToUser(DataRow dr)
 {
     User user = new User();
     user.UserID = Helpers.ConvertToInt(dr, "UserID");
     user.AspnetUserID = Helpers.ConvertToGuid(dr, "AspnetUserID");
     user.Username = Helpers.ConvertToString(dr, "Username");
     user.Email = Helpers.ConvertToString(dr, "Email");
     user.Password = Helpers.ConvertToString(dr, "Password");
     user.Status = Helpers.ConvertToInt(dr, "Status");
     user.FirstName = Helpers.ConvertToString(dr, "FirstName");
     user.LastName = Helpers.ConvertToString(dr, "LastName");
     user.Address1 = Helpers.ConvertToString(dr, "Address1");
     user.Address2 = Helpers.ConvertToString(dr, "Address2");
     user.City = Helpers.ConvertToString(dr, "City");
     user.State = Helpers.ConvertToString(dr, "State");
     user.Zip = Helpers.ConvertToString(dr, "Zip");
     user.Phone = Helpers.ConvertToString(dr, "Phone");
     user.DateCreated = Helpers.ConvertToDateTime(dr, "DateCreated");
     user.DateModified = Helpers.ConvertToDateTime(dr, "DateModified");
     return user;
 }