コード例 #1
0
 public PolicyCover EndOn(DateTime lastDateOfCover)
 {
     return(new PolicyCover
            (
                CoverCode,
                CoverPeriod.EndOn(lastDateOfCover),
                Price
            ));
 }
コード例 #2
0
        public virtual PolicyVersion EndOn(DateTime endDate)
        {
            var endedCovers = this.covers.Select(c => c.EndOn(endDate)).ToList();

            var termVersion = new PolicyVersion
            {
                Policy                = this.Policy,
                VersionNumber         = this.Policy.NextVersionNumber(),
                PolicyHolder          = new PolicyHolder(PolicyHolder.FirstName, PolicyHolder.LastName, PolicyHolder.Pesel),
                CoverPeriod           = CoverPeriod.EndOn(endDate),
                VersionValidityPeriod = ValidityPeriod.Between(endDate.AddDays(1), VersionValidityPeriod.ValidTo),
                covers                = endedCovers,
                TotalPremiumAmount    = endedCovers.Sum(c => c.Premium)
            };

            return(termVersion);
        }
コード例 #3
0
ファイル: PolicyVersion.cs プロジェクト: sharmasourabh/ddd
        public void EndPolicyOn(DateTime lastDayOfCover)
        {
            if (!IsDraft())
            {
                throw new ApplicationException("Only draft versions can be altered");
            }

            CoverPeriod = CoverPeriod.EndOn(lastDayOfCover);

            foreach (var cover in covers)
            {
                cover.EndCoverOn(lastDayOfCover);
            }

            TotalPremium = RecalculateTotal();

            PolicyStatus = PolicyStatus.Terminated;
        }
コード例 #4
0
 public void EndCoverOn(DateTime lastDayOfCover)
 {
     CoverPeriod = CoverPeriod.EndOn(lastDayOfCover);
     Amount      = CalculateAmount();
 }