public override bool UpdateUserPassword() { bool result = false; if (userKey.ToString().Length == 36 && !string.IsNullOrEmpty(oldPassword) && !string.IsNullOrEmpty(newPassword)) { using (var userUnitOfWork = new UserUnitOfWork(new AyudaContext())) { var user = userUnitOfWork.Users.GetUserByUserKey(userKey); if (user.UserId > 0) { if (SecurePasswordHelper.Verify(oldPassword, user.Password)) { user.Password = SecurePasswordHelper.Hash(newPassword); userUnitOfWork.Users.Update(user); result = userUnitOfWork.Complete() > 0; userUnitOfWork.Dispose(); } } } } return(result); }
public override int CreateUserAndRetrieveUserId() { int userId = 0; if (!string.IsNullOrEmpty(username) && !string.IsNullOrEmpty(password)) { using (var userUnitOfWOrk = new UserUnitOfWork(new AyudaContext())) { var user = new User { Username = username, Password = SecurePasswordHelper.Hash(password), EmailAddress = emailAddress, ContactNumber = contactNumber }; userUnitOfWOrk.Users.Add(user); userUnitOfWOrk.Complete(); userId = user.UserId; userUnitOfWOrk.Dispose(); } } return(userId); }