コード例 #1
0
 /// <summary>
 /// Deprecated Method for adding a new object to the Users EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToUsers(User user)
 {
     base.AddObject("Users", user);
 }
コード例 #2
0
        public bool CreateUser(CreateUserModel userModel, CreateUserProfileModel userProfileModel)
        {
            User user = new User();
            user.Username = userModel.Username;
            user.Password = userModel.Password;
            user.Email = userModel.Email;

            user.PasswordSalt = "abc123";
            user.AlternateEmail = "";
            user.LastModifiedDate = DateTime.Now;
            user.LastLoginDate = DateTime.Now;
            user.CreatedDate = DateTime.Now;
            user.IsActivated = true;
            user.IsLockedOut = false;
            user.LastLockedOutDate = DateTime.Now;
            user.SecurityQuestion = "";
            user.SecurityAnswer = "";

            UserProfile userProfile = new UserProfile();
            userProfile.FirstName = userProfileModel.FirstName;
            userProfile.LastName = userProfileModel.LastName;
            userProfile.Birthdate = userProfileModel.Birthdate;
            userProfile.IsFemale = userProfileModel.IsFemale;
            userProfile.Description = userProfileModel.Description;
            userProfile.Avatar = "/Content/Images/viewprofile.png";

            userProfile.Reputation = 0;

            user.UserProfile = userProfile;

            db.AddToUsers(user);
            db.SaveChanges();

            return true;
        }
コード例 #3
0
 /// <summary>
 /// Create a new User object.
 /// </summary>
 /// <param name="userId">Initial value of the UserId property.</param>
 /// <param name="username">Initial value of the Username property.</param>
 /// <param name="password">Initial value of the Password property.</param>
 /// <param name="passwordSalt">Initial value of the PasswordSalt property.</param>
 /// <param name="email">Initial value of the Email property.</param>
 /// <param name="alternateEmail">Initial value of the AlternateEmail property.</param>
 /// <param name="createdDate">Initial value of the CreatedDate property.</param>
 /// <param name="lastModifiedDate">Initial value of the LastModifiedDate property.</param>
 /// <param name="lastLoginDate">Initial value of the LastLoginDate property.</param>
 /// <param name="isActivated">Initial value of the IsActivated property.</param>
 /// <param name="isLockedOut">Initial value of the IsLockedOut property.</param>
 /// <param name="lastLockedOutDate">Initial value of the LastLockedOutDate property.</param>
 /// <param name="securityQuestion">Initial value of the SecurityQuestion property.</param>
 public static User CreateUser(global::System.Int32 userId, global::System.String username, global::System.String password, global::System.String passwordSalt, global::System.String email, global::System.String alternateEmail, global::System.DateTime createdDate, global::System.DateTime lastModifiedDate, global::System.DateTime lastLoginDate, global::System.Boolean isActivated, global::System.Boolean isLockedOut, global::System.DateTime lastLockedOutDate, global::System.String securityQuestion)
 {
     User user = new User();
     user.UserId = userId;
     user.Username = username;
     user.Password = password;
     user.PasswordSalt = passwordSalt;
     user.Email = email;
     user.AlternateEmail = alternateEmail;
     user.CreatedDate = createdDate;
     user.LastModifiedDate = lastModifiedDate;
     user.LastLoginDate = lastLoginDate;
     user.IsActivated = isActivated;
     user.IsLockedOut = isLockedOut;
     user.LastLockedOutDate = lastLockedOutDate;
     user.SecurityQuestion = securityQuestion;
     return user;
 }
コード例 #4
0
        public static UserModel UserToUserModel(User user)
        {
            if (user != null)
            {
                UserModel userModel = new UserModel();
                userModel.UserId = user.UserId;
                userModel.Username = user.Username;
                userModel.Password = user.Password;
                userModel.Email = user.Email;
                userModel.CreatedDate = user.CreatedDate;
                userModel.IsActivated = user.IsActivated;
                userModel.IsLockedOut = user.IsLockedOut;
                userModel.LastLoginDate = user.LastLoginDate;
                userModel.LastLockedOutDate = user.LastLockedOutDate;
                userModel.UserProfile = user.UserProfile;

                return userModel;
            }
            else
            {
                return null;
            }
        }