Skip to content

Commit e68ee2d

Browse files
[csharp][booking][04_tell_dont_ask] Add project
1 parent f8aec73 commit e68ee2d

File tree

19 files changed

+360
-0
lines changed

19 files changed

+360
-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", "{8F79B02E-9372-4232-88FC-3DE1AF80C010}"
7+
EndProject
8+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Booking", "src\Booking\Booking.csproj", "{97359721-9FD5-46BB-BAAB-348B6AA34F31}"
9+
EndProject
10+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{11FA2296-057A-4900-84BB-9C6FB2803B28}"
11+
EndProject
12+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Booking.Tests", "test\Booking.Tests\Booking.Tests.csproj", "{DED70ACC-B1DF-47ED-A830-AB409986BDC8}"
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+
{97359721-9FD5-46BB-BAAB-348B6AA34F31}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
28+
{97359721-9FD5-46BB-BAAB-348B6AA34F31}.Debug|Any CPU.Build.0 = Debug|Any CPU
29+
{97359721-9FD5-46BB-BAAB-348B6AA34F31}.Debug|x64.ActiveCfg = Debug|Any CPU
30+
{97359721-9FD5-46BB-BAAB-348B6AA34F31}.Debug|x64.Build.0 = Debug|Any CPU
31+
{97359721-9FD5-46BB-BAAB-348B6AA34F31}.Debug|x86.ActiveCfg = Debug|Any CPU
32+
{97359721-9FD5-46BB-BAAB-348B6AA34F31}.Debug|x86.Build.0 = Debug|Any CPU
33+
{97359721-9FD5-46BB-BAAB-348B6AA34F31}.Release|Any CPU.ActiveCfg = Release|Any CPU
34+
{97359721-9FD5-46BB-BAAB-348B6AA34F31}.Release|Any CPU.Build.0 = Release|Any CPU
35+
{97359721-9FD5-46BB-BAAB-348B6AA34F31}.Release|x64.ActiveCfg = Release|Any CPU
36+
{97359721-9FD5-46BB-BAAB-348B6AA34F31}.Release|x64.Build.0 = Release|Any CPU
37+
{97359721-9FD5-46BB-BAAB-348B6AA34F31}.Release|x86.ActiveCfg = Release|Any CPU
38+
{97359721-9FD5-46BB-BAAB-348B6AA34F31}.Release|x86.Build.0 = Release|Any CPU
39+
{DED70ACC-B1DF-47ED-A830-AB409986BDC8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
40+
{DED70ACC-B1DF-47ED-A830-AB409986BDC8}.Debug|Any CPU.Build.0 = Debug|Any CPU
41+
{DED70ACC-B1DF-47ED-A830-AB409986BDC8}.Debug|x64.ActiveCfg = Debug|Any CPU
42+
{DED70ACC-B1DF-47ED-A830-AB409986BDC8}.Debug|x64.Build.0 = Debug|Any CPU
43+
{DED70ACC-B1DF-47ED-A830-AB409986BDC8}.Debug|x86.ActiveCfg = Debug|Any CPU
44+
{DED70ACC-B1DF-47ED-A830-AB409986BDC8}.Debug|x86.Build.0 = Debug|Any CPU
45+
{DED70ACC-B1DF-47ED-A830-AB409986BDC8}.Release|Any CPU.ActiveCfg = Release|Any CPU
46+
{DED70ACC-B1DF-47ED-A830-AB409986BDC8}.Release|Any CPU.Build.0 = Release|Any CPU
47+
{DED70ACC-B1DF-47ED-A830-AB409986BDC8}.Release|x64.ActiveCfg = Release|Any CPU
48+
{DED70ACC-B1DF-47ED-A830-AB409986BDC8}.Release|x64.Build.0 = Release|Any CPU
49+
{DED70ACC-B1DF-47ED-A830-AB409986BDC8}.Release|x86.ActiveCfg = Release|Any CPU
50+
{DED70ACC-B1DF-47ED-A830-AB409986BDC8}.Release|x86.Build.0 = Release|Any CPU
51+
EndGlobalSection
52+
GlobalSection(NestedProjects) = preSolution
53+
{97359721-9FD5-46BB-BAAB-348B6AA34F31} = {8F79B02E-9372-4232-88FC-3DE1AF80C010}
54+
{DED70ACC-B1DF-47ED-A830-AB409986BDC8} = {11FA2296-057A-4900-84BB-9C6FB2803B28}
55+
EndGlobalSection
56+
EndGlobal
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
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 (dateRange.IsAfter(date))
34+
{
35+
return BookingStatus.NOT_STARTED;
36+
}
37+
38+
if (dateRange.IsBetween(date))
39+
{
40+
return BookingStatus.ACTIVE;
41+
}
42+
43+
return BookingStatus.FINISHED;
44+
}
45+
}
46+
}
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+
private readonly CustomerId id;
6+
private readonly CustomerName name;
7+
private readonly EmailAddress emailAddress;
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: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
using System;
2+
3+
namespace CodelyTv.Booking
4+
{
5+
public sealed class DateRange
6+
{
7+
private readonly DateTime startDate;
8+
private readonly DateTime endDate;
9+
10+
public DateRange(DateTime startDate, DateTime endDate)
11+
{
12+
this.startDate = startDate;
13+
this.endDate = endDate;
14+
}
15+
16+
public bool IsBetween(DateTime date)
17+
{
18+
return date > startDate && date < endDate;
19+
}
20+
21+
public bool IsAfter(DateTime date)
22+
{
23+
return date < startDate;
24+
}
25+
}
26+
}

0 commit comments

Comments
 (0)