Exemple #1
0
        public InsuranceQuoteResponseMessage GetQuoteUsingMessageContract(InsuranceQuoteRequestMessage requestMessage)
        {
            InsuredInfo        objInsuredInfo; //= new InsuredInfo();
            InsuranceQuoteInfo objQuoteInfo = new InsuranceQuoteInfo();

            objInsuredInfo = requestMessage.InsuredInformation;

            //Validate the Insured information sent with request message
            FaultInfo objFaultInfo = ValidateInsuredInfo(objInsuredInfo);

            if (objFaultInfo == null)
            {
                //Calculate insurance quote based on received info
                objQuoteInfo = CalculateQuote(objInsuredInfo);

                //Finally return the Quote
                InsuranceQuoteResponseMessage responseMessage = new InsuranceQuoteResponseMessage();
                responseMessage.QuoteInformation = objQuoteInfo;

                return(responseMessage);
            }
            else
            {
                throw new FaultException <FaultInfo>(objFaultInfo, objFaultInfo.Reason);
            }
        }
Exemple #2
0
        private FaultInfo ValidateInsuredInfo(InsuredInfo objInsuredInfo)
        {
            FaultInfo objFaultInfo = null;
            string    strReason    = "";
            int       intTemp      = 0;

            //Validate presence of insured data
            if (objInsuredInfo == null)
            {
                strReason = "Insured information is missing and is required.";
            }
            else
            {
                //Validate age
                if (objInsuredInfo.Age.Length == 0)
                {
                    strReason = "Insured Age is missing and is required.";
                }
                else
                {
                    if (int.TryParse(objInsuredInfo.Age, out intTemp) == false)
                    {
                        strReason = "Insured Age must be a valid numeric value.";
                    }
                }

                //Validate Vehicle Year Built
                if (objInsuredInfo.VehicleYearBuilt == -1)
                {
                    if (strReason.Length > 0)
                    {
                        strReason += "\n";
                    }

                    strReason += "Insured Vehicle Year Built is missing and is required.";
                }
            }

            if (strReason.Length > 0)
            {
                objFaultInfo = new FaultInfo(strReason);
            }

            return(objFaultInfo);
        }
Exemple #3
0
        public InsuranceQuoteInfo GetQuote(InsuredInfo insuredInformation)
        {
            InsuranceQuoteInfo objQuoteInfo = new InsuranceQuoteInfo();

            //Validate the Insured information sent with request message
            FaultInfo objFaultInfo = ValidateInsuredInfo(insuredInformation);

            if (objFaultInfo == null)
            {
                //Calculate insurance quote based on received info
                objQuoteInfo = CalculateQuote(insuredInformation);
                return(objQuoteInfo);
            }
            else
            {
                throw new FaultException <FaultInfo>(objFaultInfo, objFaultInfo.Reason);
            }
        }
        private FaultInfo ValidateInsuredInfo(InsuredInfo objInsuredInfo)
        {
            const string FAULT_REASON_MSG = "An exception has occurred. See details below:\n\n{0}";

            FaultInfo objFaultInfo = null;
            string strReason = "";
            int intTemp = 0;

            //Validate presence of insured data
            if (objInsuredInfo == null)
            {
                objFaultInfo = new FaultInfo();
                objFaultInfo.Reason = string.Format(FAULT_REASON_MSG,
                                                    "Insured information is missing and is required.");
            }
            else
            {
                //Validate age
                if (objInsuredInfo.Age.Length == 0)
                {
                    strReason = "Insured Age is missing and is required.";
                }
                else
                {
                    if (int.TryParse(objInsuredInfo.Age, out intTemp) == false)
                    {
                        strReason = "Insured Age must be a valid numeric value.";
                    }
                }

                //Validate Vehicle Year Built
                if (objInsuredInfo.VehicleYearBuilt.Length == 0)
                {
                    if (strReason.Length > 0)
                    {
                        strReason += "\nInsured Vehicle Year Built is missing and is required.";
                    }
                    else
                    {
                        strReason = "Insured Vehicle Year Built is missing and is required.";
                    }
                }
                else
                {
                    if (int.TryParse(objInsuredInfo.VehicleYearBuilt, out intTemp) == false)
                    {
                        if (strReason.Length > 0)
                        {
                            strReason += "\nInsured Vehicle Year Built must be a valid numeric value.";
                        }
                        else
                        {
                            strReason = "Insured Vehicle Year Built must be a valid numeric value.";
                        }
                    }
                }

                if (strReason.Length > 0)
                {
                    objFaultInfo = new FaultInfo();
                    objFaultInfo.Reason = string.Format(FAULT_REASON_MSG, strReason);
                }
            }

            return objFaultInfo;
        }
        private FaultInfo ValidateInsuredInfo(InsuredInfo objInsuredInfo)
        {
            const string FAULT_REASON_MSG = "An exception has occurred. See details below:\n\n{0}";

            FaultInfo objFaultInfo = null;
            string    strReason    = "";
            int       intTemp      = 0;

            //Validate presence of insured data
            if (objInsuredInfo == null)
            {
                objFaultInfo        = new FaultInfo();
                objFaultInfo.Reason = string.Format(FAULT_REASON_MSG,
                                                    "Insured information is missing and is required.");
            }
            else
            {
                //Validate age
                if (objInsuredInfo.Age.Length == 0)
                {
                    strReason = "Insured Age is missing and is required.";
                }
                else
                {
                    if (int.TryParse(objInsuredInfo.Age, out intTemp) == false)
                    {
                        strReason = "Insured Age must be a valid numeric value.";
                    }
                }

                //Validate Vehicle Year Built
                if (objInsuredInfo.VehicleYearBuilt.Length == 0)
                {
                    if (strReason.Length > 0)
                    {
                        strReason += "\nInsured Vehicle Year Built is missing and is required.";
                    }
                    else
                    {
                        strReason = "Insured Vehicle Year Built is missing and is required.";
                    }
                }
                else
                {
                    if (int.TryParse(objInsuredInfo.VehicleYearBuilt, out intTemp) == false)
                    {
                        if (strReason.Length > 0)
                        {
                            strReason += "\nInsured Vehicle Year Built must be a valid numeric value.";
                        }
                        else
                        {
                            strReason = "Insured Vehicle Year Built must be a valid numeric value.";
                        }
                    }
                }

                if (strReason.Length > 0)
                {
                    objFaultInfo        = new FaultInfo();
                    objFaultInfo.Reason = string.Format(FAULT_REASON_MSG, strReason);
                }
            }

            return(objFaultInfo);
        }
        private FaultInfo ValidateInsuredInfo(InsuredInfo objInsuredInfo)
        {
            FaultInfo objFaultInfo = null;
            string strReason = "";
            int intTemp = 0;

            //Validate presence of insured data
            if (objInsuredInfo == null)
            {
                strReason = "Insured information is missing and is required.";
            }
            else
            {
                //Validate age
                if (objInsuredInfo.Age.Length == 0)
                {
                    strReason = "Insured Age is missing and is required.";
                }
                else
                {
                    if (int.TryParse(objInsuredInfo.Age, out intTemp) == false)
                    {
                        strReason = "Insured Age must be a valid numeric value.";
                    }
                }

                //Validate Vehicle Year Built
                if (objInsuredInfo.VehicleYearBuilt == -1)
                {
                    if (strReason.Length > 0)
                    {
                        strReason += "\n";
                    }

                    strReason += "Insured Vehicle Year Built is missing and is required.";
                }
            }

            if (strReason.Length > 0)
            {
                objFaultInfo = new FaultInfo(strReason);
            }

            return objFaultInfo;
        }