diff --git a/examples/csharp/csharp-booking-03_preserve_whole_object/src/Booking/Booking.cs b/examples/csharp/csharp-booking-03_preserve_whole_object/src/Booking/Booking.cs index 66929d83..2ec2333b 100644 --- a/examples/csharp/csharp-booking-03_preserve_whole_object/src/Booking/Booking.cs +++ b/examples/csharp/csharp-booking-03_preserve_whole_object/src/Booking/Booking.cs @@ -1,15 +1,15 @@ -using System; +using System; namespace CodelyTv.Booking { public sealed class Booking { - private readonly BookingId id; - private readonly DateRange dateRange; - private readonly Customer customer; - private readonly BookingType bookingType; - private readonly Discount discount; - private readonly Tax tax; + public BookingId Id { get; } + public DateRange DateRange { get; } + public Customer Customer { get; } + public BookingType BookingType { get; } + public Discount Discount { get; } + public Tax Tax { get; } public Booking( BookingId id, @@ -20,30 +20,25 @@ public Booking( Tax tax ) { - this.id = id; - this.dateRange = dateRange; - this.customer = customer; - this.bookingType = bookingType; - this.discount = discount; - this.tax = tax; + Id = id ?? throw new ArgumentNullException(nameof(id), "Booking ID cannot be null."); + DateRange = dateRange ?? throw new ArgumentNullException(nameof(dateRange), "Date range cannot be null."); + Customer = customer ?? throw new ArgumentNullException(nameof(customer), "Customer cannot be null."); + BookingType = bookingType; + Discount = discount ?? throw new ArgumentNullException(nameof(discount), "Discount cannot be null."); + Tax = tax ?? throw new ArgumentNullException(nameof(tax), "Tax cannot be null."); } public BookingStatus StatusFor(DateTime date) { - if (date < dateRange.StartDate) + if (date < DateRange.StartDate) { return BookingStatus.NOT_STARTED; } - if (IsBetween(date, dateRange)) - { - return BookingStatus.ACTIVE; - } - - return BookingStatus.FINISHED; + return IsBetween(date, DateRange) ? BookingStatus.ACTIVE : BookingStatus.FINISHED; } - private bool IsBetween(DateTime date, DateRange dateRange) + private static bool IsBetween(DateTime date, DateRange dateRange) { return date > dateRange.StartDate && date < dateRange.EndDate; }