Exemple #1
0
        public void Rate()
        {
            Logger.Log("Starting ExecuteSomething");

            string policyJson = PolicySource.GetPolicyFromSource();

            var policy = PolicySerializer.GetPolicyFromJsonString(policyJson);

            switch (policy.Type)
            {
            case PolicyType.Auto:
                Logger.Log("Rating AUTO policy...");
                if (policy.Make == "BMW")
                {
                    if (policy.Deductible < 500)
                    {
                        Rating = 1000m;
                    }
                    Rating = 900m;
                }
                break;

            case PolicyType.Land:
                Logger.Log("Rating LAND policy...");
                if (policy.BondAmount == 0 || policy.Valuation == 0)
                {
                    Console.WriteLine("Land policy must specify Bond Amount and Valuation.");
                    return;
                }
                Rating = policy.BondAmount * 0.05m;
                break;

            case PolicyType.Life:
                Logger.Log("Rating LIFE policy...");
                int     age      = DateTime.Today.Year - policy.DateOfBirth.Year;
                decimal baseRate = policy.Amount * age / 200;
                if (policy.IsSmoker)
                {
                    Rating = baseRate * 2;
                    break;
                }
                Rating = baseRate;
                break;

            default:
                Logger.Log("Unknown policy type");
                break;
            }
        }
Exemple #2
0
        public void Rate()
        {
            Logger.Log("Starting rate.");

            Logger.Log("Loading policy.");

            string policyJson = PolicySource.GetPolicyFromSource();

            var policy = PolicySerializer.GetPolicyFromJsonString(policyJson);

            var factory = new RaterFactory();

            var rater = factory.Create(policy, this);

            rater?.Rate(policy);

            Logger.Log("Rating completed.");
        }
Exemple #3
0
        public void Rate()
        {
            Logger.Log("Starting rate.");

            Logger.Log("Loading policy.");

            var policyJson = PolicySource.GetPolicyFromSource();

            var policy = PolicySerializer.GetPolicyFromJsonString(policyJson);

            switch (policy.Type)
            {
            case PolicyType.Auto:
                Logger.Log("Rating AUTO policy...");

                Logger.Log("Validating policy.");

                if (string.IsNullOrEmpty(policy.Make))
                {
                    Logger.Log("Auto policy must specify make");

                    return;
                }

                if (policy.Make == "BMW")
                {
                    if (policy.Deductible < 500)
                    {
                        Rating = 1000m;
                    }

                    Rating = 900m;
                }

                break;

            case PolicyType.Land:
                Logger.Log("Rating LAND policy.");

                Logger.Log("Validating policy.");

                if (policy.BondAmount == 0 || policy.Valuation == 0)
                {
                    Logger.Log("Land policy must specify Bond Amount and Valuation.");

                    return;
                }

                if (policy.BondAmount < 0.8m * policy.Valuation)
                {
                    Logger.Log("Insufficient bond amount");

                    return;
                }

                Rating = policy.BondAmount * 0.05m;

                break;

            default:
                Logger.Log("Unknown policy type.");

                break;
            }

            Logger.Log("Rating completed.");
        }