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

Large Class → Extracted tax and discount logic into BookingPricing. #68

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
EduardKrutii wants to merge 2 commits into CodelyTV:main
base: main
Choose a base branch
Loading
from EduardKrutii:1
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Large Class → Extracted tax and discount logic into BookingPricing.
  • Loading branch information
EduardKrutii committed Feb 9, 2025
commit 4d665bee1c3eb879af52d709de37fbee0066f204
73 changes: 28 additions & 45 deletions examples/csharp/csharp-booking-01_base/src/Booking/Booking.cs
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -2,52 +2,35 @@

namespace CodelyTv.Booking
{
public class BookingDetails
{
public BookingId Id { get; }
public DateTime StartDate { get; }
public DateTime EndDate { get; }
public CustomerId CustomerId { get; }
public CustomerName CustomerName { get; }
public EmailAddress CustomerEmail { get; }
public BookingType BookingType { get; }
public DiscountType DiscountType { get; }
public DiscountValue DiscountValue { get; }
public TaxType TaxType { get; }
public TaxValue TaxValue { get; }

public BookingDetails(
BookingId id, DateTime startDate, DateTime endDate, CustomerId customerId,
CustomerName customerName, EmailAddress customerEmail, BookingType bookingType,
DiscountType discountType, DiscountValue discountValue, TaxType taxType, TaxValue taxValue)
public class BookingPricing
{
Id = id;
StartDate = startDate;
EndDate = endDate;
CustomerId = customerId;
CustomerName = customerName;
CustomerEmail = customerEmail;
BookingType = bookingType;
DiscountType = discountType;
DiscountValue = discountValue;
TaxType = taxType;
TaxValue = taxValue;
}
public DiscountType DiscountType { get; }
public DiscountValue DiscountValue { get; }
public TaxType TaxType { get; }
public TaxValue TaxValue { get; }

public Booking(BookingDetails details)
{
this.id = details.Id;
this.startDate = details.StartDate;
this.endDate = details.EndDate;
this.customerId = details.CustomerId;
this.customerName = details.CustomerName;
this.customerEmail = details.CustomerEmail;
this.bookingType = details.BookingType;
this.discountType = details.DiscountType;
this.discountValue = details.DiscountValue;
this.taxType = details.TaxType;
this.taxValue = details.TaxValue;
}
public BookingPricing(DiscountType discountType, DiscountValue discountValue, TaxType taxType, TaxValue taxValue)
{
DiscountType = discountType;
DiscountValue = discountValue;
TaxType = taxType;
TaxValue = taxValue;
}

private readonly BookingPricing pricing;

public Booking(BookingId id, DateTime startDate, DateTime endDate, CustomerId customerId,
CustomerName customerName, EmailAddress customerEmail, BookingType bookingType, BookingPricing pricing)
{
this.id = id;
this.startDate = startDate;
this.endDate = endDate;
this.customerId = customerId;
this.customerName = customerName;
this.customerEmail = customerEmail;
this.bookingType = bookingType;
this.pricing = pricing;
}

public BookingStatus StatusFor(DateTime date)
{
Expand All @@ -64,4 +47,4 @@ public BookingStatus StatusFor(DateTime date)
return BookingStatus.FINISHED;
}
}
}
}

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