Skip to content

Commit 9f20a8c

Browse files
[csharp][booking][01_base] Add base classes
1 parent eef0c25 commit 9f20a8c

File tree

11 files changed

+137
-0
lines changed

11 files changed

+137
-0
lines changed
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
using System;
2+
3+
namespace tv.codely.Booking
4+
{
5+
public sealed class Booking
6+
{
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;
18+
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+
}
45+
46+
public BookingStatus StatusFor(DateTime date)
47+
{
48+
if (date < startDate)
49+
{
50+
return BookingStatus.NOT_STARTED;
51+
}
52+
53+
if (date > startDate && date < endDate)
54+
{
55+
return BookingStatus.ACTIVE;
56+
}
57+
58+
return BookingStatus.FINISHED;
59+
}
60+
}
61+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
using System;
2+
3+
namespace tv.codely.Booking
4+
{
5+
public sealed class BookingId
6+
{
7+
private readonly string value;
8+
9+
public BookingId(string value) => this.value = value;
10+
}
11+
12+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
namespace tv.codely.Booking
2+
{
3+
public enum BookingStatus { NOT_STARTED, ACTIVE, FINISHED }
4+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
namespace tv.codely.Booking
2+
{
3+
public enum BookingType { VACATION, WORK }
4+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
namespace tv.codely.Booking
2+
{
3+
public sealed class CustomerId
4+
{
5+
private readonly string value;
6+
7+
public CustomerId(string value) => this.value = value;
8+
}
9+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
using System;
2+
3+
namespace tv.codely.Booking
4+
{
5+
public sealed class CustomerName
6+
{
7+
private readonly string value;
8+
9+
public CustomerName(string value) => this.value = value;
10+
}
11+
12+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
namespace tv.codely.Booking
2+
{
3+
public enum DiscountType { NONE }
4+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
namespace tv.codely.Booking
2+
{
3+
public sealed class DiscountValue
4+
{
5+
private readonly int value;
6+
7+
public DiscountValue(int value) => this.value = value;
8+
}
9+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
namespace tv.codely.Booking
2+
{
3+
public sealed class EmailAddress
4+
{
5+
private readonly string value;
6+
7+
public EmailAddress(string value) => this.value = value;
8+
}
9+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
namespace tv.codely.Booking
2+
{
3+
public enum TaxType { NONE }
4+
}

0 commit comments

Comments
 (0)