public void ShouldCreateNewUserInUserTableWithDefaultRole() { var encryptedPassword = _encryptionService.CreatePasswordHash("password", _salt); var userName = Guid.NewGuid().ToString(); var email = Guid.NewGuid().ToString(); var member = new User(userName, encryptedPassword, email) { Salt = _salt, OrgId = 2, CreatedOn = DateTime.UtcNow, CreatedBy = new Guid("{7BE26044-11B6-4042-BDF5-900722713215}") }; //using (var scope = new TransactionScope()) { using (IMemberUnitOfWork memberUow = new MemberUnitOfWork(_dBcontext)) { memberUow.CreateMember(member); memberUow.Save(); Assert.IsNotNull(member.UserGuid); Assert.AreNotEqual(member.UserGuid, Guid.Empty); memberUow.UserRepository.Delete(member); memberUow.Save(); //scope.Complete(); } //} }
public User GetUserByUserNameOrEmail(string userName, string email) { User userDto = null; using (var memberUow = new MemberUnitOfWork()) { var user = memberUow.GetUserByEmail(email) ?? memberUow.GetUserByUserName(userName); if (user != null) { userDto = Mapper.Map <User, User>(user); userDto.Application.Users = null; userDto.Organization.Users = null; userDto.Organization.OrganizationType.Organizations = null; } } return(userDto); }
public void ShouldNotCreateUserWithSameUserName() { var encryptedPassword = _encryptionService.CreatePasswordHash("password", _salt); var member = new User("testuser", encryptedPassword, "*****@*****.**") { Salt = _salt, OrgId = 2, CreatedOn = DateTime.UtcNow, CreatedBy = new Guid("{7BE26044-11B6-4042-BDF5-900722713215}") }; using (var scope = new TransactionScope()) { using (IMemberUnitOfWork memberUow = new MemberUnitOfWork(_dBcontext)) { memberUow.CreateMember(member); memberUow.Save(); Assert.IsNotNull(member.UserGuid); Assert.AreNotEqual(member.UserGuid, Guid.Empty); scope.Complete(); } } }
public Guid CreateCustomer(User customer) { var securSettings = new SecuritySettings(); var encryptionService = new EncryptionService(securSettings); var salt = encryptionService.CreateSaltKey(); customer.Salt = salt; customer.Password = encryptionService.CreatePasswordHash(customer.Password, salt); customer.PasswordFormat = 1; //"SHA1" customer.CreatedOn = DateTime.UtcNow; customer.CreatedBy = customer.CreatedBy == Guid.Empty ? new Guid(Constants.SystemAccountGuid) : customer.CreatedBy; using (var scope = new TransactionScope()) { using (var coreUow = new MemberUnitOfWork()) { coreUow.CreateMember(customer); coreUow.Save(); scope.Complete(); return(customer.UserGuid); } } }
public MemberController(MemberUnitOfWork memberUnitOfWork, IMapper mapper) { memberWork = memberUnitOfWork; autoMapper = mapper; }