コード例 #1
0
        private void AddFirstVersion(Offer offer, DateTime purchaseDate, DateTime policyStartDate)
        {
            var ver = new PolicyVersion
                      (
                Guid.NewGuid(),
                1,
                ValidityPeriod.Between(policyStartDate, policyStartDate.Add(offer.CoverPeriod)),
                PolicyStatus.Active,
                ValidityPeriod.Between(policyStartDate, policyStartDate.Add(offer.CoverPeriod)),
                offer.Customer.Copy(),
                offer.Driver.Copy(),
                offer.Car.Copy(),
                offer.TotalCost,
                offer.Covers
                      );

            versions.Add(ver);
        }
コード例 #2
0
        public void AddCover(CoverPrice coverPrice, DateTime coverStart, DateTime coverEnd)
        {
            if (!IsDraft())
            {
                throw new ApplicationException("Only draft versions can be altered");
            }

            var cover = new PolicyCover
                        (
                Guid.NewGuid(),
                coverPrice.CoverCode,
                ValidityPeriod.Between(coverStart, coverEnd),
                coverPrice.Price,
                coverPrice.CoverPeriod
                        );

            covers.Add(cover);

            TotalPremium = RecalculateTotal();
        }
コード例 #3
0
        public PolicyVersion
        (
            PolicyVersion baseVersion,
            int versionNumber,
            DateTime startDate
        )
        {
            Id                    = Guid.NewGuid();
            VersionNumber         = versionNumber;
            BaseVersionNumber     = baseVersion.VersionNumber;
            VersionValidityPeriod = ValidityPeriod.Between(startDate, baseVersion.CoverPeriod.ValidTo);
            PolicyStatus          = baseVersion.PolicyStatus;
            CoverPeriod           = ValidityPeriod.Between(baseVersion.CoverPeriod.ValidFrom, baseVersion.CoverPeriod.ValidTo);
            PolicyHolder          = baseVersion.PolicyHolder.Copy();
            Driver                = baseVersion.Driver.Copy();
            Car                   = baseVersion.Car.Copy();
            foreach (var oldCover in baseVersion.covers)
            {
                covers.Add(oldCover);
            }

            TotalPremium = RecalculateTotal();
        }