Exemplo n.º 1
0
        /*
         * Call a service to get a user by userName. It returns UserData type.
         * This method calls the utility class UserUtility to convert the data to a PersonModel object
         * and returns the PersonModel object
         * After use it disposes the UserUtility object
         */
        public UserModel GetUserByUserName(string UserName)
        {
            UserModel userModel = null;

            UserData user = null;

            try
            {
                IUserService _userClientUserName = createServiceClient();
                user = _userClientUserName.GetUserByUserName(UserName);

                if (user.UserName != null)
                {
                    userModel = UserUtility.ConvertUserDataToUserModelData(user);
                }
                else
                {
                    return(null);
                }
            }
            catch (ServiceAccessException)
            {
                throw new ServiceAccessException(ExceptionMessages.Couldnt_Retrive_User_From_Service);
            }


            return(userModel);
        }
Exemplo n.º 2
0
        /*
         * Call a service to get a user by userId. It returns UserData type.
         * This method calls the utility class UserUtility to convert the data to a PersonModel object
         * and returns the PersonModel object
         * After use it disposes the UserUtility object
         */
        public UserModel getUserId(int userId)
        {
            UserModel userModel = null;
            UserData  user;

            try
            {
                IUserService _userServiceId = createServiceClient();
                user = _userServiceId.GetUserById(userId);

                userModel = UserUtility.ConvertUserDataToUserModelData(user);
            }
            catch (ServiceAccessException)
            {
                throw new ServiceAccessException(ExceptionMessages.Couldnt_Retrive_User_From_Service);
            }


            return(userModel);
        }