예제 #1
0
        public Response <QuickRegistrationModel> Add(QuickRegistrationModel contact)
        {
            var contactDemographicsParameters = BuildQuickRegistrationSpParams(contact);
            var contactDemographicsRepository = _unitOfWork.GetRepository <QuickRegistrationModel>(SchemaName.Registration);
            var spResults = contactDemographicsRepository.ExecuteNQStoredProc("usp_AddQuickRegistration", contactDemographicsParameters);

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


            if (contact.Addresses.Count != 0)
            {
                foreach (ContactAddressModel ad in contact.Addresses)
                {
                    ad.ContactID = 1;//spResults.DataItems[0].ContactID;
                }
                var addressResults = _addressDataProvider.AddAddresses(1, contact.Addresses);

                if (addressResults.ResultCode != 0)
                {
                    spResults.ResultCode    = addressResults.ResultCode;
                    spResults.ResultMessage = addressResults.ResultMessage;
                    return(spResults);
                }
            }
            if (contact.Emails.Count != 0)
            {
                foreach (ContactEmailModel em in contact.Emails)
                {
                    em.ContactID = 1;//spResults.DataItems[0].ContactID;
                }
                var emailResults = _emailDataProvider.AddEmails(1, contact.Emails);

                if (emailResults.ResultCode != 0)
                {
                    spResults.ResultCode    = emailResults.ResultCode;
                    spResults.ResultMessage = emailResults.ResultMessage;
                    return(spResults);
                }
            }
            if (contact.Phones.Count != 0)
            {
                foreach (ContactPhoneModel ph in contact.Phones)
                {
                    ph.ContactID = 1; //spResults.DataItems[0].ContactID;
                }
                var phoneResults = _phoneDataProvider.AddPhones(1, contact.Phones);

                //if (phoneResults.ResultCode == 0) return spResults;
                if (phoneResults.ResultCode != 0)
                {
                    spResults.ResultCode    = phoneResults.ResultCode;
                    spResults.ResultMessage = phoneResults.ResultMessage;
                    return(spResults);
                }
            }
            return(spResults);
        }
예제 #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);
        }
예제 #3
0
        public Response <ReferralClientInformationModel> AddClientInformation(ReferralClientInformationModel clientInformation)
        {
            Response <ReferralClientInformationModel> clientResults = new Response <ReferralClientInformationModel>();

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

                clientResults.ID = demographicsResult.ID;
                clientInformation.referralClientAdditionalDetails.ContactID        = demographicsResult.ID;
                clientInformation.referralClientAdditionalDetails.ReferralHeaderID = clientInformation.ReferralHeaderID;

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

                if (clientInformation.Concern != null)
                {
                    clientInformation.Concern.ReferralAdditionalDetailID = additionalDetailsResult.ID;

                    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.AddAddresses(demographicsResult.ID, clientInformation.Addresses);
                    if (addressResult.ResultCode != 0)
                    {
                        clientResults.ResultCode    = addressResult.ResultCode;
                        clientResults.ResultMessage = addressResult.ResultMessage;
                        return(clientResults);
                    }
                }

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

                unitOfWork.TransactionScopeComplete(transactionScope);
            }
            return(clientResults);
        }