public async Task <IActionResult> Post([FromBody] Customer customer)
        {
            ActionResult       result;
            var                input = new SaveCustomerInput();
            SaveCustomerOutput output;

            try
            {
                input.Customer = customer;
                output         = await this._facadeOrchestratorCustomer.SaveCustomerAsync(input);

                if (output.Success)
                {
                    result = Created("api/customer", customer);
                }
                else
                {
                    result = BadRequest(output.GetJoinedErrors());
                }
            }
            catch (Exception ex)
            {
                result = BadRequest(ex);
            }

            return(result);
        }
        public void CreateIndividualSampleCode1()
        {
            try
            {
                //Create an individual Customer with 1 address linked to employer and another individual address
                var a = new DataServiceCollection <SaveAddressInput>(null, TrackingMode.None);

                //Address linked to a company
                SaveAddressInput a1 = new SaveAddressInput()
                {
                    AddressTypeCode = "WORK",
                    //Address1 = "One DesCombes Drive",
                    City        = "Broomfield",
                    State       = "CO",
                    PostalCode  = "80020",
                    CountryCode = "USA",
                    OverrideAddressValidation     = false,
                    SetRelationshipAsPrimary      = true,
                    PrimaryAddress                = true,
                    CreateNewAddressIfOrdersExist = true,
                    EndOldPrimaryRelationship     = true,
                    WebMobileDirectory            = true,
                };

                a.Add(a1);


                SaveCustomerInput s = new SaveCustomerInput()
                {
                    FirstName         = "Troy_New_Member",
                    LastName          = "Fulton",
                    CustomerClassCode = "INDIV",

                    Addresses = a,
                };

                SaveCustomerOutput op = SvcClient.Post <SaveCustomerOutput>("CreateIndividual", s);
                op.Equals(op);
            }
            catch (Exception ex)
            {
                var message = ex.Message;

                var messages = message.ParseXML <Messages>();

                throw ex;
            }
        }
        public void CreateIndividualSampleCode2()
        {
            try
            {
                //Create an individual Customer with 1 address linked to employer and another individual address
                var a = new DataServiceCollection <SaveAddressInput>(null, TrackingMode.None);

                SaveCustomerInput s = new SaveCustomerInput()
                {
                    FirstName         = "Troy",
                    LastName          = "Fulton",
                    CustomerClassCode = "INDIV"
                };

                SaveCustomerOutput op = SvcClient.Post <SaveCustomerOutput>("CreateIndividual", s);
                op.Equals(op);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Example #4
0
    /// <summary>
    /// Create customer personify info object
    /// </summary>
    /// <param name="firstName">firstName</param>
    /// <param name="lastName">lastName</param>
    public bool CreateCustomerInf(string userName, string firstName, string lastName)
    {
        string personifyAddress = string.Empty, address1 = string.Empty, address2 = string.Empty, city = string.Empty, state = string.Empty, zip = string.Empty, country = string.Empty;
        bool   custInfCreated = false;

        try
        {
            FormEngineUserControl PersonifyAddress = formUser.FieldControls["PersonifyAddress"];
            if (PersonifyAddress != null)
            {
                personifyAddress = ValidationHelper.GetString(PersonifyAddress.Value, String.Empty);
            }
            var address = personifyAddress.Split('|');
            address1 = address[0];
            address2 = address[1];
            city     = address[2];
            state    = address[3];
            country  = address[4];
            zip      = address[5];
            //Create an individual Customer with 1 address linked to employer and another individual address
            var a = new DataServiceCollection <SaveAddressInput>(null, TrackingMode.None);

            //Address linked to a company
            SaveAddressInput a1 = new SaveAddressInput()
            {
                AddressTypeCode               = "WORK",
                Address1                      = address1,
                Address2                      = address2,
                City                          = city,
                State                         = state,
                PostalCode                    = zip,
                CountryCode                   = country,
                OverrideAddressValidation     = false,
                SetRelationshipAsPrimary      = true,
                PrimaryAddress                = true,
                CreateNewAddressIfOrdersExist = true,
                EndOldPrimaryRelationship     = true,
                WebMobileDirectory            = true,
            };

            a.Add(a1);

            CusCommunicationInput emailInput = new CusCommunicationInput();
            emailInput.CommLocationCode      = "WORK";
            emailInput.CommTypeCode          = "EMAIL";
            emailInput.PrimaryFlag           = true;
            emailInput.ActiveFlag            = true;
            emailInput.CountryCode           = country;
            emailInput.FormattedPhoneAddress = userName;

            SaveCustomerInput s = new SaveCustomerInput()
            {
                FirstName         = firstName,
                LastName          = lastName,
                CustomerClassCode = "INDIV",
                Addresses         = a,
                Communication     = new DataServiceCollection <CusCommunicationInput>(null, TrackingMode.None)
            };

            s.Communication.Add(emailInput);


            SaveCustomerOutput op = PersonifyDataServiceClient.Post <SaveCustomerOutput>("CreateIndividual", s);

            if (!String.IsNullOrEmpty(op.MasterCustomerId))
            {
                var newIdentifier = op.MasterCustomerId + "|0";
                custInfCreated = true;
                var result = ssoClient.TIMSSCustomerIdentifierSet(PersonifyVendorName, PersonifyVendorPassword, userName, newIdentifier);

                custInfCreated = result.CustomerIdentifier == newIdentifier;

                if (!custInfCreated)
                {
                    throw new Exception(result.Errors.FirstOrDefault());
                }

                FormEngineUserControl txtEducationLevel = formUser.FieldControls["EducationLevel"];
                if (txtEducationLevel != null)
                {
                    var educationLevel = ValidationHelper.GetString(txtEducationLevel.Value, String.Empty);

                    if (!String.IsNullOrEmpty(educationLevel))
                    {
                        var demo1 = PersonifyDataServiceClient.Create <CusDemographicList>();
                        demo1.MasterCustomerId   = op.MasterCustomerId;
                        demo1.SubCustomerId      = op.SubCustomerId;
                        demo1.DemographicCode    = "EDUC_LEVEL";
                        demo1.DemographicSubcode = educationLevel;
                        var result1 = PersonifyDataServiceClient.Save <CusDemographicList>(demo1);
                    }
                }

                FormEngineUserControl txtReferralSource = formUser.FieldControls["ReferralSource"];
                if (txtReferralSource != null)
                {
                    var referralSource = ValidationHelper.GetString(txtReferralSource.Value, String.Empty);

                    if (!String.IsNullOrEmpty(referralSource))
                    {
                        var demo2 = PersonifyDataServiceClient.Create <CusDemographicList>();
                        demo2.MasterCustomerId   = op.MasterCustomerId;
                        demo2.SubCustomerId      = op.SubCustomerId;
                        demo2.DemographicCode    = "REFERRAL_SOURCE";
                        demo2.DemographicSubcode = referralSource;
                        var result2 = PersonifyDataServiceClient.Save <CusDemographicList>(demo2);
                    }
                }

                FormEngineUserControl txtInterestArea = formUser.FieldControls["InterestArea"];
                if (txtInterestArea != null)
                {
                    var interestArea = ValidationHelper.GetString(txtInterestArea.Value, String.Empty);

                    if (!String.IsNullOrEmpty(interestArea))
                    {
                        var demo3 = PersonifyDataServiceClient.Create <CusDemographicList>();
                        demo3.MasterCustomerId   = op.MasterCustomerId;
                        demo3.SubCustomerId      = op.SubCustomerId;
                        demo3.DemographicCode    = "INT_AREA";
                        demo3.DemographicSubcode = interestArea;
                        var result3 = PersonifyDataServiceClient.Save <CusDemographicList>(demo3);
                    }
                }

                FormEngineUserControl txtIndustry = formUser.FieldControls["Industry"];
                if (txtIndustry != null)
                {
                    var industry = ValidationHelper.GetString(txtIndustry.Value, String.Empty);

                    if (!String.IsNullOrEmpty(industry))
                    {
                        var demo4 = PersonifyDataServiceClient.Create <CusDemographicList>();
                        demo4.MasterCustomerId   = op.MasterCustomerId;
                        demo4.SubCustomerId      = op.SubCustomerId;
                        demo4.DemographicCode    = "INDUSTRY";
                        demo4.DemographicSubcode = industry;

                        var result4 = PersonifyDataServiceClient.Save <CusDemographicList>(demo4);
                    }
                }
            }
            else
            {
                throw new Exception("created individual, but master customer id was empty.");
            }
        }
        catch (DataServiceClientException ex)
        {
            //disable customer account
            ssoClient.SSOEnableDisableCustomerAccount(PersonifyVendorName, PersonifyVendorPassword, userName, true);
            custInfCreated = false;
            throw ex;
        }
        return(custInfCreated);
    }
Example #5
0
        public async Task <SaveCustomerOutput> SaveCustomerAsync(SaveCustomerInput input)
        {
            SaveCustomerOutput output = await Orchestrator.Execute <SaveCustomer, SaveCustomerInput, SaveCustomerOutput, SaveCustomerValidator>(_customerManager, input);

            return(output);
        }