Skip to content

Commit

Permalink
Update: Filtering added, relationships revised
Browse files Browse the repository at this point in the history
  • Loading branch information
ademclk committed Mar 20, 2023
1 parent 1af654f commit 06fca54
Show file tree
Hide file tree
Showing 16 changed files with 1,065 additions and 51 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,7 @@ public record CreateFlightCommand(
string? AircraftId,
string? DepartureAirportId,
string? ArrivalAirportId,
string? PriceId
string? EconomyPriceId,
string? ComfortPriceId,
string? BusinessPriceId
) : IRequest<ErrorOr<Flight>>;
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ public async Task<ErrorOr<Flight>> Handle(CreateFlightCommand request, Cancellat
var aircraftId = AircraftId.Create(Guid.Parse(request.AircraftId!));
var departureAirportId = AirportId.Create(Guid.Parse(request.DepartureAirportId!));
var arrivalAirportId = AirportId.Create(Guid.Parse(request.ArrivalAirportId!));
var priceId = PriceId.Create(Guid.Parse(request.PriceId!));
var ePriceId = PriceId.Create(Guid.Parse(request.EconomyPriceId!));
var cPriceId = PriceId.Create(Guid.Parse(request.ComfortPriceId!));
var bPriceId = PriceId.Create(Guid.Parse(request.BusinessPriceId!));

var flight = Flight.Create(
request.FlightNumber,
Expand All @@ -36,7 +38,9 @@ public async Task<ErrorOr<Flight>> Handle(CreateFlightCommand request, Cancellat
aircraftId,
departureAirportId,
arrivalAirportId,
priceId);
ePriceId,
cPriceId,
bPriceId);

await _flightRepository.AddFlightAsync(flight);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ public async Task<ErrorOr<List<FlightDto>>> Handle(SearchFlightQuery request, Ca
var flights = await _flightRepository.SearchFlightsAsync(
request.DepartureAirportIataCode!,
request.ArrivalAirportIataCode!,
departureDate.ToUniversalTime(),
returnDate.ToUniversalTime(),
departureDate,
returnDate,
request.PassengerCount);

return flights;
Expand Down
4 changes: 3 additions & 1 deletion Ceyehat.Contracts/Flights/CreateFlightRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,7 @@ public record CreateFlightRequest(
string? AircraftId,
string? DepartureAirportId,
string? ArrivalAirportId,
string? PriceId
string? EconomyPriceId,
string? ComfortPriceId,
string? BusinessPriceId
);
4 changes: 3 additions & 1 deletion Ceyehat.Contracts/Flights/FlightResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ public record FlightResponse(
string? AircraftId,
string? DepartureAirportId,
string ArrivalAirportId,
string? PriceId,
string? EconomyPriceId,
string? ComfortPriceId,
string? BusinessPriceId,
DateTime CreatedAt,
DateTime UpdatedAt
);
Expand Down
20 changes: 15 additions & 5 deletions Ceyehat.Domain/FlightAggregate/Flight.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ public sealed class Flight : AggregateRoot<FlightId>
public AircraftId AircraftId { get; private set; }
public AirportId DepartureAirportId { get; private set; }
public AirportId ArrivalAirportId { get; private set; }
public PriceId PriceId { get; private set; }
public PriceId EconomyPriceId { get; private set; }
public PriceId ComfortPriceId { get; private set; }
public PriceId BusinessPriceId { get; private set; }

public DateTime CreatedAt { get; private set; }
public DateTime UpdatedAt { get; private set; }
Expand All @@ -37,7 +39,9 @@ private Flight(
AircraftId aircraftId,
AirportId departureAirportId,
AirportId arrivalAirportId,
PriceId priceId,
PriceId economyPriceId,
PriceId comfortPriceId,
PriceId businessPriceId,
DateTime createdAt,
DateTime updatedAt) : base(flightId)
{
Expand All @@ -51,7 +55,9 @@ private Flight(
AircraftId = aircraftId;
DepartureAirportId = departureAirportId;
ArrivalAirportId = arrivalAirportId;
PriceId = priceId;
EconomyPriceId = economyPriceId;
ComfortPriceId = comfortPriceId;
BusinessPriceId = businessPriceId;
CreatedAt = createdAt;
UpdatedAt = updatedAt;
}
Expand All @@ -67,7 +73,9 @@ public static Flight Create(
AircraftId aircraftId,
AirportId departureAirport,
AirportId arrivalAirport,
PriceId priceId)
PriceId economyPriceId,
PriceId comfortPriceId,
PriceId businessPriceId)
{
return new Flight(
FlightId.CreateUnique(),
Expand All @@ -81,7 +89,9 @@ public static Flight Create(
aircraftId,
departureAirport,
arrivalAirport,
priceId,
economyPriceId,
comfortPriceId,
businessPriceId,
DateTime.UtcNow,
DateTime.UtcNow);
}
Expand Down
Loading

0 comments on commit 06fca54

Please sign in to comment.