예제 #1
0
 public UserData UserRegister(UserData dataObject)
 {
     try {
         return userService.UserRegister(dataObject);
     }
     catch(Exception ex) {
         ILog Log = LogManager.GetLogger("AppService", MethodBase.GetCurrentMethod().DeclaringType);
         Log.Error(ex);
         throw new FaultException<FaultData>(FaultData.CreateFromException(ex), FaultData.CreateFaultReason(ex));
     }
 }
예제 #2
0
 public UserData UserRegister(UserData dataObject)
 {
     if (dataObject == null)
         throw new ArgumentNullException("userDataObject");
     using (IRepositoryContext context = IocLocator.Instance.GetImple<IRepositoryContext>()) {
         IRepository<User> userRepository = context.GetRepository<User>();
         if (userRepository.Exists(Specification<User>.Eval(c => c.Email == dataObject.Email)))
             throw new DomainException("Customer with the Email of '{0}' already exists.", dataObject.Email);
         User user = Mapper.Map<UserData, User>(dataObject);
         user.Register();
         userRepository.Add(user);
         context.Commit();
         return Mapper.Map<User, UserData>(user);
     }
 }
예제 #3
0
 public void UserUpdate(String userkey, UserData dataObject)
 {
     try {
          userService.UserUpdate(userkey, dataObject);
     }
     catch(Exception ex) {
         ILog Log = LogManager.GetLogger("AppService", MethodBase.GetCurrentMethod().DeclaringType);
         Log.Error(ex);
         throw new FaultException<FaultData>(FaultData.CreateFromException(ex), FaultData.CreateFaultReason(ex));
     }
 }
예제 #4
0
        public void UserUpdate(string userkey, UserData dataObject)
        {
            if (string.IsNullOrEmpty(userkey))
                throw new ArgumentNullException("email");
            if (dataObject == null)
                throw new ArgumentNullException("dataObject");

            using (IRepositoryContext context = IocLocator.Instance.GetImple<IRepositoryContext>()) {
                var userRepository = context.GetRepository<User>();
                var user = userRepository.Get(Specification<User>.Eval(c => c.Email == userkey));
                if (!string.IsNullOrEmpty(dataObject.PasswordHash))
                    user.PasswordHash = dataObject.PasswordHash;
                if (!string.IsNullOrEmpty(dataObject.Name))
                    user.Name = dataObject.Name;
                if (!string.IsNullOrEmpty(dataObject.Link))
                    user.Link = dataObject.Link;
                if (!string.IsNullOrEmpty(dataObject.QQ))
                    user.QQ = dataObject.QQ;
                if (!string.IsNullOrEmpty(dataObject.Weibo))
                    user.Weibo = dataObject.Weibo;
                if (dataObject.RoleEnum != 0)
                    user.RoleEnum = dataObject.RoleEnum;
                if (dataObject.ActEnum != 0)
                    user.ActEnum = dataObject.ActEnum;
                if (dataObject.DateLastLogin.HasValue)
                    user.DateLastLogin = dataObject.DateLastLogin;
                if (dataObject.DateLastPasswordChange.HasValue)
                    user.DateLastPasswordChange = dataObject.DateLastPasswordChange;
                userRepository.Update(user);
            }
        }