From 79d6c4eafd2a0b735c4adfe5146ed70326132eb3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20B=C4=85czek?= <74410956+kamilbaczek@users.noreply.github.com> Date: Thu, 1 Feb 2024 07:44:14 +0100 Subject: [PATCH] refactor: rename binding contract initialization --- .../Src/Fitnet.Contracts.Core/Contract.cs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/Chapter-4-applying-tactical-domain-driven-design/Fitnet.Contracts/Src/Fitnet.Contracts.Core/Contract.cs b/Chapter-4-applying-tactical-domain-driven-design/Fitnet.Contracts/Src/Fitnet.Contracts.Core/Contract.cs index 64618306..8ec00f7e 100644 --- a/Chapter-4-applying-tactical-domain-driven-design/Fitnet.Contracts/Src/Fitnet.Contracts.Core/Contract.cs +++ b/Chapter-4-applying-tactical-domain-driven-design/Fitnet.Contracts/Src/Fitnet.Contracts.Core/Contract.cs @@ -43,19 +43,17 @@ public static Contract Prepare(Guid customerId, int customerAge, int customerHei StandardDuration); } - internal BindingContract Sign(DateTimeOffset signedAt, DateTimeOffset dateNow) + public BindingContract Sign(DateTimeOffset signedAt, DateTimeOffset dateNow) { - if (IsSigned) - { - throw new ContractAlreadySignedException(); - } + BusinessRuleValidator.Validate( + new ContractMustNotBeAlreadySigned(IsSigned)); BusinessRuleValidator.Validate( new ContractCanOnlyBeSignedWithin30DaysFromPreparation(PreparedAt, signedAt)); SignedAt = signedAt; var expiringAt = dateNow.Add(Duration); - var bindingContract = BindingContract.Acceptance(Id, CustomerId, Duration, expiringAt); + var bindingContract = BindingContract.Start(Id, CustomerId, Duration, expiringAt); return bindingContract; }