Skip to content

Commit 17a1d40

Browse files
Merge branch 'csharp-booking-04'
2 parents 6cf9918 + e68ee2d commit 17a1d40

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+1083
-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", "{26CCBDA1-0811-47E7-92BA-A4749674B8E4}"
7+
EndProject
8+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Booking", "src\Booking\Booking.csproj", "{70A618E2-11BC-454B-84D4-A0DE26F2D296}"
9+
EndProject
10+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{4E771359-5709-4FE7-A7B4-A956EC611D14}"
11+
EndProject
12+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Booking.Tests", "test\Booking.Tests\Booking.Tests.csproj", "{7B3CC2C7-A8EF-4538-AD15-229794D1F16C}"
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+
{70A618E2-11BC-454B-84D4-A0DE26F2D296}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
28+
{70A618E2-11BC-454B-84D4-A0DE26F2D296}.Debug|Any CPU.Build.0 = Debug|Any CPU
29+
{70A618E2-11BC-454B-84D4-A0DE26F2D296}.Debug|x64.ActiveCfg = Debug|Any CPU
30+
{70A618E2-11BC-454B-84D4-A0DE26F2D296}.Debug|x64.Build.0 = Debug|Any CPU
31+
{70A618E2-11BC-454B-84D4-A0DE26F2D296}.Debug|x86.ActiveCfg = Debug|Any CPU
32+
{70A618E2-11BC-454B-84D4-A0DE26F2D296}.Debug|x86.Build.0 = Debug|Any CPU
33+
{70A618E2-11BC-454B-84D4-A0DE26F2D296}.Release|Any CPU.ActiveCfg = Release|Any CPU
34+
{70A618E2-11BC-454B-84D4-A0DE26F2D296}.Release|Any CPU.Build.0 = Release|Any CPU
35+
{70A618E2-11BC-454B-84D4-A0DE26F2D296}.Release|x64.ActiveCfg = Release|Any CPU
36+
{70A618E2-11BC-454B-84D4-A0DE26F2D296}.Release|x64.Build.0 = Release|Any CPU
37+
{70A618E2-11BC-454B-84D4-A0DE26F2D296}.Release|x86.ActiveCfg = Release|Any CPU
38+
{70A618E2-11BC-454B-84D4-A0DE26F2D296}.Release|x86.Build.0 = Release|Any CPU
39+
{7B3CC2C7-A8EF-4538-AD15-229794D1F16C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
40+
{7B3CC2C7-A8EF-4538-AD15-229794D1F16C}.Debug|Any CPU.Build.0 = Debug|Any CPU
41+
{7B3CC2C7-A8EF-4538-AD15-229794D1F16C}.Debug|x64.ActiveCfg = Debug|Any CPU
42+
{7B3CC2C7-A8EF-4538-AD15-229794D1F16C}.Debug|x64.Build.0 = Debug|Any CPU
43+
{7B3CC2C7-A8EF-4538-AD15-229794D1F16C}.Debug|x86.ActiveCfg = Debug|Any CPU
44+
{7B3CC2C7-A8EF-4538-AD15-229794D1F16C}.Debug|x86.Build.0 = Debug|Any CPU
45+
{7B3CC2C7-A8EF-4538-AD15-229794D1F16C}.Release|Any CPU.ActiveCfg = Release|Any CPU
46+
{7B3CC2C7-A8EF-4538-AD15-229794D1F16C}.Release|Any CPU.Build.0 = Release|Any CPU
47+
{7B3CC2C7-A8EF-4538-AD15-229794D1F16C}.Release|x64.ActiveCfg = Release|Any CPU
48+
{7B3CC2C7-A8EF-4538-AD15-229794D1F16C}.Release|x64.Build.0 = Release|Any CPU
49+
{7B3CC2C7-A8EF-4538-AD15-229794D1F16C}.Release|x86.ActiveCfg = Release|Any CPU
50+
{7B3CC2C7-A8EF-4538-AD15-229794D1F16C}.Release|x86.Build.0 = Release|Any CPU
51+
EndGlobalSection
52+
GlobalSection(NestedProjects) = preSolution
53+
{70A618E2-11BC-454B-84D4-A0DE26F2D296} = {26CCBDA1-0811-47E7-92BA-A4749674B8E4}
54+
{7B3CC2C7-A8EF-4538-AD15-229794D1F16C} = {4E771359-5709-4FE7-A7B4-A956EC611D14}
55+
EndGlobalSection
56+
EndGlobal
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
using System;
2+
3+
namespace CodelyTv.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+
DateRange bookingDateRange,
22+
Customer customer,
23+
BookingType bookingType,
24+
Discount discount,
25+
Tax tax
26+
)
27+
{
28+
this.id = id;
29+
this.startDate = bookingDateRange.StartDate;
30+
this.endDate = bookingDateRange.EndDate;
31+
this.customerId = customer.Id;
32+
this.customerName = customer.Name;
33+
this.customerEmail = customer.EmailAddress;
34+
this.bookingType = bookingType;
35+
this.discountType = discount.Type;
36+
this.discountValue = discount.Value;
37+
this.taxType = tax.Type;
38+
this.taxValue = tax.Value;
39+
}
40+
41+
public BookingStatus StatusFor(DateTime date)
42+
{
43+
if (date < startDate)
44+
{
45+
return BookingStatus.NOT_STARTED;
46+
}
47+
48+
if (date > startDate && date < endDate)
49+
{
50+
return BookingStatus.ACTIVE;
51+
}
52+
53+
return BookingStatus.FINISHED;
54+
}
55+
}
56+
}
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)