Beispiel #1
0
        /// <summary>
        /// Gets the contact.
        /// </summary>
        /// <param name="contactID">The contact identifier</param>
        /// <param name="contactTypeID">The contact type identifier</param>
        /// <returns>Response</returns>
        public virtual Response <Model> GetContact(long contactID, int?contactTypeID)
        {
            //var procsParameters = new List<SqlParameter> { new SqlParameter("ContactID", contactID) };
            var procsParameters = BuildContactGetParams(contactID, contactTypeID);

            var contactRepository = _unitOfWork.GetRepository <Model>(SchemaName.Registration);
            var contactResults    = contactRepository.ExecuteStoredProc(GetStoredProcedureName, procsParameters);

            if (contactResults == null || contactResults.ResultCode != 0)
            {
                return(contactResults);
            }

            if (contactResults.DataItems.Count == 0)
            {
                return(contactResults);
            }
            var addressResults = _addressDataProvider.GetAddresses(contactID, contactTypeID);

            if (addressResults.ResultCode != 0)
            {
                contactResults.ResultCode    = addressResults.ResultCode;
                contactResults.ResultMessage = addressResults.ResultMessage;
            }
            else
            {
                contactResults.DataItems.ForEach(m =>
                {
                    m.Addresses =
                        (addressResults.DataItems.Where(a => a.ContactID == m.ContactID).OrderByDescending(a => a.IsPrimary).ThenByDescending(a => a.ContactAddressID).Take(1).ToList());
                });
            }
            var phoneResults = _phoneDataProvider.GetPhones(contactID, contactTypeID);

            if (phoneResults.ResultCode != 0)
            {
                contactResults.ResultCode    = phoneResults.ResultCode;
                contactResults.ResultMessage = phoneResults.ResultMessage;
            }
            else
            {
                contactResults.DataItems.ForEach(m =>
                {
                    m.Phones = (phoneResults.DataItems.Where(a => a.ContactID == m.ContactID).OrderByDescending(a => a.IsPrimary).ThenByDescending(a => a.ContactPhoneID).Take(1).ToList());
                });
            }

            var emailResults = _emailDataProvider.GetEmails(contactID, contactTypeID);

            if (emailResults.ResultCode != 0)
            {
                contactResults.ResultCode    = emailResults.ResultCode;
                contactResults.ResultMessage = emailResults.ResultMessage;
            }
            else
            {
                contactResults.DataItems.ForEach(m =>
                {
                    m.Emails = (emailResults.DataItems.Where(a => a.ContactID == m.ContactID).OrderByDescending(a => a.IsPrimary).ThenByDescending(a => a.ContactEmailID).Take(1).ToList());
                });
            }

            var clientIdentifierResults = _clientIdentifierDataProvider.GetContactClientIdentifiers(contactID);

            if (clientIdentifierResults.ResultCode != 0)
            {
                contactResults.ResultCode    = clientIdentifierResults.ResultCode;
                contactResults.ResultMessage = clientIdentifierResults.ResultMessage;
            }
            else
            {
                contactResults.DataItems.ForEach(m =>
                {
                    m.ClientAlternateIDs = (clientIdentifierResults.DataItems.Where(a => a.ContactID == m.ContactID).ToList());
                });
            }


            return(contactResults);
        }
Beispiel #2
0
        public Response <ReferralClientInformationModel> GetClientInformation(long ReferralHeaderID)
        {
            var clientInformationResult = new Response <ReferralClientInformationModel>();

            var clientAdditionalDetails = clientAdditionalDetailsDataProvider.GetClientAdditionalDetail(ReferralHeaderID);

            if (clientAdditionalDetails.ResultCode != 0)
            {
                clientInformationResult.ResultCode    = clientAdditionalDetails.ResultCode;
                clientInformationResult.ResultMessage = clientInformationResult.ResultMessage;
                return(clientInformationResult);
            }

            if (clientAdditionalDetails != null && clientAdditionalDetails.DataItems.Count > 0)
            {
                var additionalDetail   = clientAdditionalDetails.DataItems.FirstOrDefault();
                var clientDemographics = clientDemographicsDataProvider.GetClientDemographics(additionalDetail.ContactID);
                if (clientDemographics.ResultCode != 0)
                {
                    clientInformationResult.ResultCode    = clientDemographics.ResultCode;
                    clientInformationResult.ResultMessage = clientDemographics.ResultMessage;
                    return(clientInformationResult);
                }

                var clientConcern = clientConcernDataProvider.GetClientConcern(additionalDetail.ReferralAdditionalDetailID);
                if (clientConcern.ResultCode != 0)
                {
                    clientInformationResult.ResultCode    = clientConcern.ResultCode;
                    clientInformationResult.ResultMessage = clientConcern.ResultMessage;
                    return(clientInformationResult);
                }

                var clientAddresses = addressDataProvider.GetAddresses(additionalDetail.ContactID, 5);
                if (clientAddresses.ResultCode != 0)
                {
                    clientInformationResult.ResultCode    = clientAddresses.ResultCode;
                    clientInformationResult.ResultMessage = clientAddresses.ResultMessage;
                    return(clientInformationResult);
                }

                var clientPhones = phoneDataProvider.GetPhones(additionalDetail.ContactID, 5);
                if (clientPhones.ResultCode != 0)
                {
                    clientInformationResult.ResultCode    = clientPhones.ResultCode;
                    clientInformationResult.ResultMessage = clientPhones.ResultMessage;
                    return(clientInformationResult);
                }

                clientInformationResult.DataItems = new List <ReferralClientInformationModel> {
                    new ReferralClientInformationModel
                    {
                        referralClientAdditionalDetails = additionalDetail,
                        clientDemographicsModel         = clientDemographics.DataItems.FirstOrDefault(),
                        Concern   = clientConcern.DataItems.FirstOrDefault(),
                        Addresses = clientAddresses.DataItems,
                        Phones    = clientPhones.DataItems
                    }
                };
            }

            return(clientInformationResult);
        }
Beispiel #3
0
 public IHttpActionResult GetContactPhones(long contactID, int?contactTypeID)
 {
     return(new HttpResult <Response <ContactPhoneModel> >(contactPhoneDataProvider.GetPhones(contactID, contactTypeID), Request));
 }