internal void Map(UserDetailsModel userDetailsModel, User user) { user.UserRoleId = userDetailsModel.UserRoleId; user.UserName = userDetailsModel.UserName; user.First = userDetailsModel.First; user.Last = userDetailsModel.Last; user.Email = userDetailsModel.Email; }
internal void Map(User user, UserDetailsModel userDetailsModel) { userDetailsModel.UserId = user.Id; userDetailsModel.UserRoleId = user.UserRoleId; userDetailsModel.UserRoleName = UserRoleModel.GetName(user.UserRoleId); userDetailsModel.UserName = user.UserName; userDetailsModel.First = user.First; userDetailsModel.Last = user.Last; userDetailsModel.Email = user.Email; }
public int CreateUser(UserDetailsModel userDetails) { ThrowBadDataIf(CheckUserNameExists(userDetails.UserName), "UserName exists"); var user = Map<User>(userDetails); user.PasswordSalt = Cryptography.CreateSalt(); user.PasswordHash = Cryptography.HashPassword(userDetails.Password, user.PasswordSalt); user.PasswordLength = userDetails.Password.Length; return userDetails.UserId = InsertAndSave(Map<User>(userDetails)).Id; }
public void UpdateUser(UserDetailsModel userDetails) { var user = EnsureFindSingle<User>(userDetails.UserId); ThrowBadDataIf(userDetails.UserName != user.UserName && CheckUserNameExists(userDetails.UserName), "UserName exists"); Map(userDetails, user); if (userDetails.Password != string.Concat(Enumerable.Repeat("*", user.PasswordLength))) { user.PasswordHash = Cryptography.HashPassword( userDetails.Password, user.PasswordSalt); user.PasswordLength = userDetails.Password.Length; } UpdateAndSave(user); }