Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 2a7095e

Browse files
Long Parameter List → Introduced a DTO (BookingDetails).
1 parent de397ea commit 2a7095e

File tree

1 file changed

+45
-39
lines changed
  • examples/csharp/csharp-booking-01_base/src/Booking

1 file changed

+45
-39
lines changed

‎examples/csharp/csharp-booking-01_base/src/Booking/Booking.cs‎

Lines changed: 45 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -2,46 +2,52 @@
22

33
namespace CodelyTv.Booking
44
{
5-
public sealed class Booking
5+
public class BookingDetails
6+
{
7+
public BookingId Id { get; }
8+
public DateTime StartDate { get; }
9+
public DateTime EndDate { get; }
10+
public CustomerId CustomerId { get; }
11+
public CustomerName CustomerName { get; }
12+
public EmailAddress CustomerEmail { get; }
13+
public BookingType BookingType { get; }
14+
public DiscountType DiscountType { get; }
15+
public DiscountValue DiscountValue { get; }
16+
public TaxType TaxType { get; }
17+
public TaxValue TaxValue { get; }
18+
19+
public BookingDetails(
20+
BookingId id, DateTime startDate, DateTime endDate, CustomerId customerId,
21+
CustomerName customerName, EmailAddress customerEmail, BookingType bookingType,
22+
DiscountType discountType, DiscountValue discountValue, TaxType taxType, TaxValue taxValue)
623
{
7-
private readonly BookingId id;
8-
private readonly DateTime startDate;
9-
private readonly DateTime endDate;
10-
private readonly CustomerId customerId;
11-
private readonly CustomerName customerName;
12-
private readonly EmailAddress customerEmail;
13-
private readonly BookingType bookingType;
14-
private readonly DiscountType discountType;
15-
private readonly DiscountValue discountValue;
16-
private readonly TaxType taxType;
17-
private readonly TaxValue taxValue;
24+
Id = id;
25+
StartDate = startDate;
26+
EndDate = endDate;
27+
CustomerId = customerId;
28+
CustomerName = customerName;
29+
CustomerEmail = customerEmail;
30+
BookingType = bookingType;
31+
DiscountType = discountType;
32+
DiscountValue = discountValue;
33+
TaxType = taxType;
34+
TaxValue = taxValue;
35+
}
1836

19-
public Booking(
20-
BookingId id,
21-
DateTime startDate,
22-
DateTime endDate,
23-
CustomerId customerId,
24-
CustomerName customerName,
25-
EmailAddress customerEmail,
26-
BookingType bookingType,
27-
DiscountType discountType,
28-
DiscountValue discountValue,
29-
TaxType taxType,
30-
TaxValue taxValue
31-
)
32-
{
33-
this.id = id;
34-
this.startDate = startDate;
35-
this.endDate = endDate;
36-
this.customerId = customerId;
37-
this.customerName = customerName;
38-
this.customerEmail = customerEmail;
39-
this.bookingType = bookingType;
40-
this.discountType = discountType;
41-
this.discountValue = discountValue;
42-
this.taxType = taxType;
43-
this.taxValue = taxValue;
44-
}
37+
public Booking(BookingDetails details)
38+
{
39+
this.id = details.Id;
40+
this.startDate = details.StartDate;
41+
this.endDate = details.EndDate;
42+
this.customerId = details.CustomerId;
43+
this.customerName = details.CustomerName;
44+
this.customerEmail = details.CustomerEmail;
45+
this.bookingType = details.BookingType;
46+
this.discountType = details.DiscountType;
47+
this.discountValue = details.DiscountValue;
48+
this.taxType = details.TaxType;
49+
this.taxValue = details.TaxValue;
50+
}
4551

4652
public BookingStatus StatusFor(DateTime date)
4753
{
@@ -58,4 +64,4 @@ public BookingStatus StatusFor(DateTime date)
5864
return BookingStatus.FINISHED;
5965
}
6066
}
61-
}
67+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /