Beispiel #1
0
 private void ExpectFactoryCalls(int repeatCount)
 {
     Expect.Call(_emailFactory.CreateEmail(null)).IgnoreArguments()
     .Return(new Email(string.Empty, string.Empty)).Repeat.Times(2 * repeatCount);
     Expect.Call(_phoneNumberFactory.CreatePhoneNumber(null, 0)).IgnoreArguments()
     .Return(new PhoneNumber(null, null, 0)).Repeat.Times(3 * repeatCount);
     Expect.Call(_userLoginFactory.CreateUserLogin(null)).IgnoreArguments()
     .Return(new UserLogin(0)).Repeat.Times(repeatCount);
 }
 public UserLogin GetByUserName(string userName)
 {
     using (var myAdapter = PersistenceLayer.GetDataAccessAdapter())
     {
         var linqMetaData = new LinqMetaData(myAdapter);
         var userLogin    = linqMetaData.UserLogin.SingleOrDefault(ul => ul.UserName == userName);
         if (userLogin == null)
         {
             throw new ObjectNotFoundInPersistenceException <UserLogin>();
         }
         return(_userLoginFactory.CreateUserLogin(userLogin));
     }
 }
Beispiel #3
0
        public UserType CreateUser(UserEntity userEntity, Address address, bool useUserLoginInfo = true)
        {
            if (userEntity == null)
            {
                throw new ArgumentNullException("userEntity");
            }

            // this workaround is necessary because although C# generics allow a default constructor constraint on a type, they do not allow
            // constraints for parameterized constructors.
            var user = (UserType)Activator.CreateInstance(typeof(UserType), userEntity.UserId);

            user.Address     = address;
            user.DateOfBirth = userEntity.Dob;


            user.Email          = !string.IsNullOrEmpty(userEntity.Email1) ? new Email(userEntity.Email1) : new Email(string.Empty, string.Empty);
            user.AlternateEmail = !string.IsNullOrEmpty(userEntity.Email2) ? new Email(userEntity.Email2) : new Email(string.Empty, string.Empty);

            user.HomePhoneNumber   = _phoneNumberFactory.CreatePhoneNumber(userEntity.PhoneHome, PhoneNumberType.Home);
            user.MobilePhoneNumber = _phoneNumberFactory.CreatePhoneNumber(userEntity.PhoneCell, PhoneNumberType.Mobile);
            user.Name = new Name(userEntity.FirstName, userEntity.MiddleName, userEntity.LastName);
            user.OfficePhoneNumber    = _phoneNumberFactory.CreatePhoneNumber(userEntity.PhoneOffice, PhoneNumberType.Office);
            user.PhoneOfficeExtension = userEntity.PhoneOfficeExtension;
            if (useUserLoginInfo)
            {
                user.UserLogin = _userLoginFactory.CreateUserLogin(userEntity.UserLogin);
            }
            if (userEntity.DefaultRoleId != null)
            {
                user.DefaultRole = (Roles)userEntity.DefaultRoleId.Value;
            }

            user.DataRecorderMetaData = new DataRecorderMetaData
            {
                DateCreated  = userEntity.DateCreated,
                DateModified = userEntity.DateModified
            };
            user.Ssn = !string.IsNullOrEmpty(userEntity.Ssn) ? _cryptographyService.Decrypt(userEntity.Ssn) : string.Empty;

            return(user);
        }