private ByteartRetailMembershipUser ConvertFrom(UserDataObject userObj)
        {
            if (userObj == null)
                return null;

            ByteartRetailMembershipUser user = new ByteartRetailMembershipUser("ByteartRetailMembershipProvider",
                userObj.UserName, 
                userObj.ID, 
                userObj.Email, 
                "", 
                "", 
                true, 
                userObj.IsDisabled ?? true,
                userObj.DateRegistered ?? DateTime.MinValue, 
                userObj.DateLastLogon ?? DateTime.MinValue, 
                DateTime.MinValue,
                DateTime.MinValue, 
                DateTime.MinValue,
                userObj.Contact,
                userObj.PhoneNumber,
                userObj.ContactAddress,
                userObj.DeliveryAddress);

            return user;
        }
		public Boolean EnableUser(UserDataObject userDataObject)
		{
			try
			{
				return _userServiceImpl.EnableUser(userDataObject);
			}
			catch(Exception ex)
			{
				throw new FaultException<FaultData>(FaultData.CreateFromException(ex), FaultData.CreateFaultReason(ex));
			}
		}
 public static UserAccountModel CreateFromDataObject(UserDataObject d)
 {
     return new UserAccountModel
     {
         ID = d.ID,
         UserName = d.UserName,
         Password = d.Password,
         Email = d.Email,
         IsDisabled = d.IsDisabled,
         DateRegistered = d.DateRegistered,
         DateLastLogon = d.DateLastLogon,
         Role = d.Role,
         Contact = d.Contact,
         PhoneNumber = d.PhoneNumber,
         ContactAddress_City = d.ContactAddress.City,
         ContactAddress_Street = d.ContactAddress.Street,
         ContactAddress_State = d.ContactAddress.State,
         ContactAddress_Country = d.ContactAddress.Country,
         ContactAddress_Zip = d.ContactAddress.Zip,
         DeliveryAddress_City = d.DeliveryAddress.City,
         DeliveryAddress_Street = d.DeliveryAddress.Street,
         DeliveryAddress_State = d.DeliveryAddress.State,
         DeliveryAddress_Country = d.DeliveryAddress.Country,
         DeliveryAddress_Zip = d.DeliveryAddress.Zip,
     };
 }
Ejemplo n.º 4
0
 /// <summary>
 /// 启用指定用户。
 /// </summary>
 /// <param name="userDataObject">需要启用的用户。</param>
 /// <returns>如果成功,则返回true,否则返回false。</returns>
 public bool EnableUser(UserDataObject userDataObject)
 {
     if (userDataObject == null)
         throw new ArgumentNullException("userDataObject");
     User user = null;
     if (!IsEmptyGuidString(userDataObject.ID))
         user = userRepository.GetByKey(new Guid(userDataObject.ID));
     else if (!string.IsNullOrEmpty(userDataObject.UserName))
         user = userRepository.GetUserByName(userDataObject.UserName);
     else if (!string.IsNullOrEmpty(userDataObject.Email))
         user = userRepository.GetUserByEmail(userDataObject.Email);
     else
         throw new ArgumentNullException("userDataObject", "Either ID, UserName or Email should be specified.");
     user.Enable();
     userRepository.Update(user);
     Context.Commit();
     return user.IsDisabled;
 }