コード例 #1
0
        private void ProcessOLSEnrollmentQuestions(string quoteNumber, string storeId, bool? paperlessFlag)
        {
            System.Data.DataTable result = DirectWebDAC.GetOLSEnrollmentValues(quoteNumber);
            var EmailVerificationCode = GetEmailVerificationCode();
            bool paperlessSelected = paperlessFlag == true;
            bool callRecalc = false;
            IQuoteConfiguration config = IQuoteConfiguration.GetConfigurationInstance();
            string emailTemplateName = config.Setting("DiscountCodeEmailTemplate");
            // If OLSStatus is not in the correct status skip this logic and only update the row if it exists
            if (this.BusinessLogic().QHeader.OLSStatus >= OlsStatusPaperlessStoredId)
            {
                // New Quote insert the row into the table and send an email
                if (result.Rows.Count == 0)
                {
                    //  Need to call InitiateToken Call Here and pass in call below.
                    string token = InitiateOLSToken();

                    if (!token.Equals(String.Empty) && !String.IsNullOrEmpty(quoteNumber))
                    {
                        DirectWebDAC.InsertOLSEnrollmentValues(quoteNumber, storeId, paperlessSelected,
                                                               EmailVerificationCode, this.BusinessLogic().QData.email,
                                                               token);
                    }
                    else if (String.IsNullOrEmpty(quoteNumber))
                    {
                        //Call failed update OLSStatus
                        this.BusinessLogic().QHeader.OLSStatus = OlsStatusPaperlessStoredIdNegative;
                    }

                    QuoteServices olsServices = new QuoteServices();

                    if (!string.IsNullOrEmpty(QData.email) && !olsServices.ValidateOLSEmail(QData.email))
                    {
                        // Insert values into BatchEmailMessageQueue

                        DirectWebDAC.InsertValidationEmail(QHeader.PartnerId, quoteNumber, QData.email, QData.firstName, QData.lastName, EmailVerificationCode, storeId, paperlessSelected, config.PartnerName, emailTemplateName);
                    }
                    else
                    {
                        // User disregarded the error and will not get a discount
                        this.BusinessLogic().QHeader.OLSStatus = OlsStatusEmailAlreadyEnrolled; // OLSStatus for invalid email
                    }
                }
                // Quote exists in the table update the row
                else
                {
                    // Check if the email is a new email, if it is update the email and the email veri
                    if (!result.Rows[0]["emailAddress"].Equals(this.BusinessLogic().QData.email))
                    {
                        // Call to get new token from OLS and pass in call below
                        string token = InitiateOLSToken();

                        if (!token.Equals(String.Empty) && !String.IsNullOrEmpty(quoteNumber))
                        {
                            DirectWebDAC.UpdateOLSEnrollment(quoteNumber, storeId, paperlessSelected,
                                                                 EmailVerificationCode, this.BusinessLogic().QData.email,
                                                                   token);
                            UpdateDefaultWalmartDiscount("ASSOCIATE15");
                        }
                        else if (String.IsNullOrEmpty(quoteNumber))
                        {
                            //Call failed update OLSStatus
                            this.BusinessLogic().QHeader.OLSStatus = OlsStatusPaperlessStoredIdNegative;
                        }

                        QuoteServices olsServices = new QuoteServices();
                        if (!string.IsNullOrEmpty(QData.email) && !olsServices.ValidateOLSEmail(QData.email))
                        {
                            // Insert values into BatchEmailMessageQueue
                            DirectWebDAC.InsertValidationEmail(QHeader.PartnerId, quoteNumber, QData.email, QData.firstName, QData.lastName, EmailVerificationCode, storeId, paperlessSelected, config.PartnerName, emailTemplateName);

                            // Clear discount code and set callRecalc to true.
                            callRecalc = true;
                            //this.BusinessLogic().Quote.AutoPolicyNumber = String.Empty;
                            //this.BusinessLogic().QData.cvgPartnerDiscount = String.Empty;

                            if (qHeader.H04Ui_V2 == false)
                            {
                                // We do not need to call rating again for non-h04V2 states as this is called twice after the about you page.
                                callRecalc = false;
                            }

                            this.BusinessLogic().Quote.Save();
                        }
                        else
                        {
                            // User disregarded the error an will not get a discount
                            this.BusinessLogic().QHeader.OLSStatus = OlsStatusEmailAlreadyEnrolled; // OLSStatus for invalid email
                        }
                    }
                    // update the storeId as all other feilds will be unchanged.
                    else if (!result.Rows[0]["CustomerTrackingId"].Equals(this.BusinessLogic().QData.storeID))
                    {
                        DirectWebDAC.UpdateOLSEnrollment(quoteNumber, storeId, paperlessSelected,
                                                         result.Rows[0]["emailverificationcode"].ToString(),
                                                         this.BusinessLogic().QData.email, result.Rows[0]["Token"].ToString());
                    }
                    else if (!result.Rows[0]["PaperlessFlag"].Equals(this.BusinessLogic().QData.paperless))
                    {
                        DirectWebDAC.UpdateOLSEnrollment(quoteNumber, storeId, paperlessSelected,
                                                         result.Rows[0]["emailverificationcode"].ToString(),
                                                         this.BusinessLogic().QData.email, result.Rows[0]["Token"].ToString());
                        this.BusinessLogic().QHeader.OLSStatus = OlsStatusPaperlessStoredId;
                    }
                }
            }
            // update the row even if the OLSStatus is not 1 to update the storeId and Paperless.
            // Do not allow the email to be updated as this will cause issue if OLSStatus becomes 1.
            else if (result.Rows.Count != 0)
            {
                DirectWebDAC.UpdateOLSEnrollment(quoteNumber, storeId, paperlessSelected,
                                                         result.Rows[0]["emailverificationcode"].ToString(), result.Rows[0]["emailAddress"].ToString(), result.Rows[0]["Token"].ToString());

                // Check to see if the user removed their storeid or unselected paperless.
                if (string.IsNullOrEmpty(storeId) || paperlessSelected == false)
                {
                    if (this.BusinessLogic().QHeader.H04Ui_V2)
                    {
                        callRecalc = true;
                    }

                    this.BusinessLogic().Quote.AutoPolicyNumber = String.Empty;
                    this.BusinessLogic().QData.cvgPartnerDiscount = String.Empty;
                    this.BusinessLogic().Quote.Save();
                }
            }

            // If we make a change that requires a new rating call then call it here.
            if (callRecalc)
            {

                this.ServiceInterface.CallRatingService();
                //Strip out default
                if (this.BusinessLogic().Quote.AutoPolicyNumber.Equals("ASSOCIATE15"))
                {
                    this.BusinessLogic().Quote.AutoPolicyNumber = String.Empty;
                    this.BusinessLogic().QData.cvgPartnerDiscount = String.Empty;
                }

            }
        }