Beispiel #1
0
        /// <summary>
        /// Perform Address,Phone,Email Add update operations
        /// </summary>
        /// <param name="contact"></param>
        /// <param name="spResults"></param>
        /// <returns></returns>
        public virtual bool ContactOtherOperations(Model contact, Response <Model> spResults)
        {
            Response <ContactAddressModel> addressResults = null;

            if (contact.CopyContactAddress)
            {
                var address = contact.Addresses.Select(a => { a.AddressID = null; return(a); });
                addressResults = addressDataProvider.CopyContactAddresses(spResults.ID, address.ToList());
            }
            else
            {
                addressResults = addressDataProvider.UpdateAddresses(spResults.ID, contact.Addresses);
            }
            if (addressResults.ResultCode != 0)
            {
                spResults.ResultCode    = addressResults.ResultCode;
                spResults.ResultMessage = addressResults.ResultMessage;
                return(false);
            }

            var emailResults = emailDataProvider.UpdateEmails(spResults.ID, contact.Emails);

            if (emailResults.ResultCode != 0)
            {
                spResults.ResultCode    = emailResults.ResultCode;
                spResults.ResultMessage = emailResults.ResultMessage;
                return(false);
            }

            var phoneResults = phoneDataProvider.UpdatePhones(spResults.ID, contact.Phones);

            if (phoneResults.ResultCode != 0)
            {
                spResults.ResultCode    = phoneResults.ResultCode;
                spResults.ResultMessage = phoneResults.ResultMessage;
                return(false);
            }

            var clientIdentifierResults = clientIdentifierDataProvider.AddUpdateContactClientIdentifiers(spResults.ID, contact.ClientAlternateIDs);

            if (clientIdentifierResults.ResultCode != 0)
            {
                spResults.ResultCode    = clientIdentifierResults.ResultCode;
                spResults.ResultMessage = clientIdentifierResults.ResultMessage;
                return(false);
            }

            return(true);
        }
Beispiel #2
0
        public IHttpActionResult AddUpdateContactPhones(ContactPhoneModel contactPhoneModel)
        {
            HttpResult <Response <ContactPhoneModel> > result = null;
            List <ContactPhoneModel> contactPhoneModelList    = new List <ContactPhoneModel>()
            {
                contactPhoneModel
            };

            if (contactPhoneModel.ContactPhoneID == 0)
            {
                result = new HttpResult <Response <ContactPhoneModel> >(contactPhoneDataProvider.AddPhones(contactPhoneModel.ContactID, contactPhoneModelList), Request);
            }
            else
            {
                result = new HttpResult <Response <ContactPhoneModel> >(contactPhoneDataProvider.UpdatePhones(contactPhoneModel.ContactID, contactPhoneModelList), Request);
            }

            return(result);
        }
Beispiel #3
0
        public Response <ReferralClientInformationModel> UpdateClientInformation(ReferralClientInformationModel clientInformation)
        {
            Response <ReferralClientInformationModel> clientResults = new Response <ReferralClientInformationModel>();

            clientResults.ResultCode = 0;

            var contactID = clientInformation.clientDemographicsModel.ContactID;

            if (contactID <= 0)
            {
                clientResults.ResultCode = -1;
                return(clientResults);
            }

            using (var transactionScope = unitOfWork.BeginTransactionScope())
            {
                Response <ContactDemographicsModel> demographicsResult =
                    clientDemographicsDataProvider.UpdateClientDemographics(clientInformation.clientDemographicsModel);
                if (demographicsResult.ResultCode != 0)
                {
                    clientResults.ResultCode    = demographicsResult.ResultCode;
                    clientResults.ResultMessage = demographicsResult.ResultMessage;
                    return(clientResults);
                }

                Response <ReferralClientAdditionalDetailsModel> additionalDetailsResult =
                    clientAdditionalDetailsDataProvider.UpdateClientAdditionalDetail(clientInformation.referralClientAdditionalDetails);
                if (additionalDetailsResult.ResultCode != 0)
                {
                    clientResults.ResultCode    = additionalDetailsResult.ResultCode;
                    clientResults.ResultMessage = additionalDetailsResult.ResultMessage;
                    return(clientResults);
                }

                if (clientInformation.Concern != null)
                {
                    clientInformation.Concern.ReferralAdditionalDetailID = clientInformation.referralClientAdditionalDetails.ReferralAdditionalDetailID;
                    Response <ReferralClientConcernsModel> concernsResult =
                        clientConcernDataProvider.AddUpdateClientConcern(clientInformation.Concern);
                    if (concernsResult.ResultCode != 0)
                    {
                        clientResults.ResultCode    = concernsResult.ResultCode;
                        clientResults.ResultMessage = concernsResult.ResultMessage;
                        return(clientResults);
                    }
                }

                if (clientInformation.Addresses != null)
                {
                    Response <ContactAddressModel> addressResult =
                        addressDataProvider.UpdateAddresses(contactID, clientInformation.Addresses);
                    if (addressResult.ResultCode != 0)
                    {
                        clientResults.ResultCode    = addressResult.ResultCode;
                        clientResults.ResultMessage = addressResult.ResultMessage;
                        return(clientResults);
                    }
                }

                if (clientInformation.Phones != null)
                {
                    Response <ContactPhoneModel> phoneResult =
                        phoneDataProvider.UpdatePhones(contactID, clientInformation.Phones);
                    if (phoneResult.ResultCode != 0)
                    {
                        clientResults.ResultCode    = phoneResult.ResultCode;
                        clientResults.ResultMessage = phoneResult.ResultMessage;
                        return(clientResults);
                    }
                }

                unitOfWork.TransactionScopeComplete(transactionScope);
            }

            return(clientResults);
        }