mirror of
https://github.com/meysamhadeli/booking-microservices.git
synced 2026-05-03 11:21:53 +08:00
Resolve issues
This commit is contained in:
parent
343d0d63c6
commit
188a121ad5
@ -33,10 +33,6 @@
|
|||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="7.0.2" />
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="7.0.2" />
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="7.0.2">
|
|
||||||
<PrivateAssets>all</PrivateAssets>
|
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
|
||||||
</PackageReference>
|
|
||||||
<PackageReference Include="Microsoft.Extensions.DependencyModel" Version="7.0.0" />
|
<PackageReference Include="Microsoft.Extensions.DependencyModel" Version="7.0.0" />
|
||||||
<PackageReference Include="Mongo2Go" Version="3.1.3" />
|
<PackageReference Include="Mongo2Go" Version="3.1.3" />
|
||||||
<PackageReference Include="Npgsql" Version="7.0.1" />
|
<PackageReference Include="Npgsql" Version="7.0.1" />
|
||||||
|
|||||||
@ -17,7 +17,7 @@ public class AirportConfiguration : IEntityTypeConfiguration<Airport>
|
|||||||
builder.HasKey(r => r.Id);
|
builder.HasKey(r => r.Id);
|
||||||
builder.Property(r => r.Id).ValueGeneratedNever()
|
builder.Property(r => r.Id).ValueGeneratedNever()
|
||||||
.HasConversion<Guid>(airportId => airportId.Value, dbId => AirportId.Of(dbId));
|
.HasConversion<Guid>(airportId => airportId.Value, dbId => AirportId.Of(dbId));
|
||||||
|
// // ref: https://learn.microsoft.com/en-us/ef/core/saving/concurrency?tabs=fluent-api
|
||||||
builder.Property(r => r.Version).IsConcurrencyToken();
|
builder.Property(r => r.Version).IsConcurrencyToken();
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,3 @@
|
|||||||
using System;
|
|
||||||
using BuildingBlocks.Core.Model;
|
using BuildingBlocks.Core.Model;
|
||||||
|
|
||||||
namespace Flight.Flights.Models;
|
namespace Flight.Flights.Models;
|
||||||
@ -8,7 +7,6 @@ using Airports.ValueObjects;
|
|||||||
using Features.CreatingFlight.V1;
|
using Features.CreatingFlight.V1;
|
||||||
using Features.DeletingFlight.V1;
|
using Features.DeletingFlight.V1;
|
||||||
using Features.UpdatingFlight.V1;
|
using Features.UpdatingFlight.V1;
|
||||||
using global::Flight.Flights.Exceptions;
|
|
||||||
using global::Flight.Flights.ValueObjects;
|
using global::Flight.Flights.ValueObjects;
|
||||||
|
|
||||||
public record Flight : Aggregate<FlightId>
|
public record Flight : Aggregate<FlightId>
|
||||||
@ -29,8 +27,6 @@ public record Flight : Aggregate<FlightId>
|
|||||||
AirportId arriveAirportId, DurationMinutes durationMinutes, FlightDate flightDate, Enums.FlightStatus status,
|
AirportId arriveAirportId, DurationMinutes durationMinutes, FlightDate flightDate, Enums.FlightStatus status,
|
||||||
Price price, bool isDeleted = false)
|
Price price, bool isDeleted = false)
|
||||||
{
|
{
|
||||||
//SimpleFlightValidate(departureDate.Value, arriveDate.Value, flightDate.Value);
|
|
||||||
|
|
||||||
var flight = new Flight
|
var flight = new Flight
|
||||||
{
|
{
|
||||||
Id = id,
|
Id = id,
|
||||||
@ -103,27 +99,4 @@ public record Flight : Aggregate<FlightId>
|
|||||||
|
|
||||||
AddDomainEvent(@event);
|
AddDomainEvent(@event);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void SimpleFlightValidate(DateTime departureDate, DateTime arriveDate, DateTime flightDate)
|
|
||||||
{
|
|
||||||
if (departureDate >= arriveDate)
|
|
||||||
{
|
|
||||||
throw new FlightExceptions(departureDate, arriveDate);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (flightDate < departureDate || flightDate > arriveDate)
|
|
||||||
{
|
|
||||||
throw new FlightExceptions(flightDate);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static TimeSpan GetFlightDuration(DateTime departureDate, DateTime arriveDate)
|
|
||||||
{
|
|
||||||
return arriveDate - departureDate;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static bool IsOnSameDay(DateTime departureDate, DateTime arriveDate)
|
|
||||||
{
|
|
||||||
return departureDate.Date == arriveDate.Date;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user