Skip to content

Commit f8aec73

Browse files
[csharp][booking][03_preserve_whole_object] Add project
1 parent ab453e1 commit f8aec73

File tree

19 files changed

+359
-0
lines changed

19 files changed

+359
-0
lines changed
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio 15
4+
VisualStudioVersion = 15.0.26124.0
5+
MinimumVisualStudioVersion = 15.0.26124.0
6+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{9CC31E46-0896-4F6C-89D8-EA045CF7DA13}"
7+
EndProject
8+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Booking", "src\Booking\Booking.csproj", "{07FFD799-5125-418B-A922-18E3EE4553D5}"
9+
EndProject
10+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{0B1B04D0-A319-4850-A2C0-FAFB74B1D19C}"
11+
EndProject
12+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Booking.Tests", "test\Booking.Tests\Booking.Tests.csproj", "{1F7EF3CD-8153-40D7-9054-0B0A02D761B3}"
13+
EndProject
14+
Global
15+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
16+
Debug|Any CPU = Debug|Any CPU
17+
Debug|x64 = Debug|x64
18+
Debug|x86 = Debug|x86
19+
Release|Any CPU = Release|Any CPU
20+
Release|x64 = Release|x64
21+
Release|x86 = Release|x86
22+
EndGlobalSection
23+
GlobalSection(SolutionProperties) = preSolution
24+
HideSolutionNode = FALSE
25+
EndGlobalSection
26+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
27+
{07FFD799-5125-418B-A922-18E3EE4553D5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
28+
{07FFD799-5125-418B-A922-18E3EE4553D5}.Debug|Any CPU.Build.0 = Debug|Any CPU
29+
{07FFD799-5125-418B-A922-18E3EE4553D5}.Debug|x64.ActiveCfg = Debug|Any CPU
30+
{07FFD799-5125-418B-A922-18E3EE4553D5}.Debug|x64.Build.0 = Debug|Any CPU
31+
{07FFD799-5125-418B-A922-18E3EE4553D5}.Debug|x86.ActiveCfg = Debug|Any CPU
32+
{07FFD799-5125-418B-A922-18E3EE4553D5}.Debug|x86.Build.0 = Debug|Any CPU
33+
{07FFD799-5125-418B-A922-18E3EE4553D5}.Release|Any CPU.ActiveCfg = Release|Any CPU
34+
{07FFD799-5125-418B-A922-18E3EE4553D5}.Release|Any CPU.Build.0 = Release|Any CPU
35+
{07FFD799-5125-418B-A922-18E3EE4553D5}.Release|x64.ActiveCfg = Release|Any CPU
36+
{07FFD799-5125-418B-A922-18E3EE4553D5}.Release|x64.Build.0 = Release|Any CPU
37+
{07FFD799-5125-418B-A922-18E3EE4553D5}.Release|x86.ActiveCfg = Release|Any CPU
38+
{07FFD799-5125-418B-A922-18E3EE4553D5}.Release|x86.Build.0 = Release|Any CPU
39+
{1F7EF3CD-8153-40D7-9054-0B0A02D761B3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
40+
{1F7EF3CD-8153-40D7-9054-0B0A02D761B3}.Debug|Any CPU.Build.0 = Debug|Any CPU
41+
{1F7EF3CD-8153-40D7-9054-0B0A02D761B3}.Debug|x64.ActiveCfg = Debug|Any CPU
42+
{1F7EF3CD-8153-40D7-9054-0B0A02D761B3}.Debug|x64.Build.0 = Debug|Any CPU
43+
{1F7EF3CD-8153-40D7-9054-0B0A02D761B3}.Debug|x86.ActiveCfg = Debug|Any CPU
44+
{1F7EF3CD-8153-40D7-9054-0B0A02D761B3}.Debug|x86.Build.0 = Debug|Any CPU
45+
{1F7EF3CD-8153-40D7-9054-0B0A02D761B3}.Release|Any CPU.ActiveCfg = Release|Any CPU
46+
{1F7EF3CD-8153-40D7-9054-0B0A02D761B3}.Release|Any CPU.Build.0 = Release|Any CPU
47+
{1F7EF3CD-8153-40D7-9054-0B0A02D761B3}.Release|x64.ActiveCfg = Release|Any CPU
48+
{1F7EF3CD-8153-40D7-9054-0B0A02D761B3}.Release|x64.Build.0 = Release|Any CPU
49+
{1F7EF3CD-8153-40D7-9054-0B0A02D761B3}.Release|x86.ActiveCfg = Release|Any CPU
50+
{1F7EF3CD-8153-40D7-9054-0B0A02D761B3}.Release|x86.Build.0 = Release|Any CPU
51+
EndGlobalSection
52+
GlobalSection(NestedProjects) = preSolution
53+
{07FFD799-5125-418B-A922-18E3EE4553D5} = {9CC31E46-0896-4F6C-89D8-EA045CF7DA13}
54+
{1F7EF3CD-8153-40D7-9054-0B0A02D761B3} = {0B1B04D0-A319-4850-A2C0-FAFB74B1D19C}
55+
EndGlobalSection
56+
EndGlobal
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
using System;
2+
3+
namespace CodelyTv.Booking
4+
{
5+
public sealed class Booking
6+
{
7+
private readonly BookingId id;
8+
private readonly DateRange dateRange;
9+
private readonly Customer customer;
10+
private readonly BookingType bookingType;
11+
private readonly Discount discount;
12+
private readonly Tax tax;
13+
14+
public Booking(
15+
BookingId id,
16+
DateRange dateRange,
17+
Customer customer,
18+
BookingType bookingType,
19+
Discount discount,
20+
Tax tax
21+
)
22+
{
23+
this.id = id;
24+
this.dateRange = dateRange;
25+
this.customer = customer;
26+
this.bookingType = bookingType;
27+
this.discount = discount;
28+
this.tax = tax;
29+
}
30+
31+
public BookingStatus StatusFor(DateTime date)
32+
{
33+
if (date < dateRange.StartDate)
34+
{
35+
return BookingStatus.NOT_STARTED;
36+
}
37+
38+
if (IsBetween(date, dateRange))
39+
{
40+
return BookingStatus.ACTIVE;
41+
}
42+
43+
return BookingStatus.FINISHED;
44+
}
45+
46+
private bool IsBetween(DateTime date, DateRange dateRange)
47+
{
48+
return date > dateRange.StartDate && date < dateRange.EndDate;
49+
}
50+
}
51+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFramework>net5.0</TargetFramework>
5+
<RootNamespace>CodelyTv.Booking</RootNamespace>
6+
</PropertyGroup>
7+
8+
</Project>
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
using System;
2+
3+
namespace CodelyTv.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 CodelyTv.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 CodelyTv.Booking
2+
{
3+
public enum BookingType { VACATION, WORK }
4+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
namespace CodelyTv.Booking
2+
{
3+
public sealed class Customer
4+
{
5+
public CustomerId Id { get; }
6+
public CustomerName Name { get; }
7+
public EmailAddress EmailAddress { get; }
8+
9+
public Customer(CustomerId id, CustomerName name, EmailAddress emailAddress)
10+
{
11+
this.Id = id;
12+
this.Name = name;
13+
this.EmailAddress = emailAddress;
14+
}
15+
}
16+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
namespace CodelyTv.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 CodelyTv.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: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
7+
namespace CodelyTv.Booking
8+
{
9+
public sealed class DateRange
10+
{
11+
public DateTime StartDate { get; }
12+
public DateTime EndDate { get; }
13+
14+
public DateRange(DateTime startDate, DateTime endDate)
15+
{
16+
this.StartDate = startDate;
17+
this.EndDate = endDate;
18+
}
19+
}
20+
}

0 commit comments

Comments
 (0)