gov.va.medora.mdws.SecureMessageLib.getUser C# (CSharp) Method

getUser() public method

public getUser ( string pwd, string userId, string idType ) : SmUserTO
pwd string
userId string
idType string
return gov.va.medora.mdws.dto.sm.SmUserTO
        public SmUserTO getUser(string pwd, string userId, string idType)
        {
            SmUserTO result = new SmUserTO();

            if (String.IsNullOrEmpty(pwd))
            {
                result.fault = new dto.FaultTO("Must supply password");
            }
            else if (String.IsNullOrEmpty(userId))
            {
                result.fault = new dto.FaultTO("Must supply user ID");
            }
            else if (String.IsNullOrEmpty(idType) && !StringUtils.isNumeric(userId))
            {
                result.fault = new FaultTO("Invalid user ID");
            }
            else if (!String.IsNullOrEmpty(idType) && !String.Equals(idType, "SMID", StringComparison.CurrentCultureIgnoreCase) &&
                !String.Equals(idType, "ICN", StringComparison.CurrentCultureIgnoreCase) && !String.Equals(idType, "SSN", StringComparison.CurrentCultureIgnoreCase))
            {
                result.fault = new FaultTO("Invalid id type", "Use one of the following: SMID, ICN, SSN");
            }

            if (result.fault != null)
            {
                return result;
            }

            try
            {
                using (MdoOracleConnection cxn = new MdoOracleConnection(new mdo.DataSource() { ConnectionString = pwd }))
                {
                    UserDao dao = new UserDao(cxn);

                    if (String.IsNullOrEmpty(idType) || String.Equals(idType, "SMID", StringComparison.CurrentCultureIgnoreCase))
                    {
                        result = new SmUserTO(dao.getUserDetail(Convert.ToInt32(userId)));
                    }
                    else if (String.Equals(idType, "ICN", StringComparison.CurrentCultureIgnoreCase))
                    {
                        result = new SmUserTO(dao.getUserDetail(dao.getUserByIcn(userId).Id));
                    }
                    else if (String.Equals(idType, "SSN", StringComparison.CurrentCultureIgnoreCase))
                    {
                        // TODO - write get user by SSN function
                        result.fault = new FaultTO("SSN lookup not currently enabled. Please try again later");
                        //result = new SmUserTO(dao.getUserDetail(dao.getUserBySsn(userId)));
                    }
                    else
                    {
                        throw new Exception("Invalid user type"); // should never get here with fault handling section but... just in case
                    }
                }
            }
            catch (Exception exc)
            {
                result.fault = new dto.FaultTO(exc);
            }

            return result;
        }