Resolve issues

This commit is contained in:
amir.gholami 2023-06-11 18:24:55 +03:30
parent 343d0d63c6
commit 188a121ad5
3 changed files with 1 additions and 32 deletions

View File

@ -33,10 +33,6 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<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="Mongo2Go" Version="3.1.3" />
<PackageReference Include="Npgsql" Version="7.0.1" />

View File

@ -17,7 +17,7 @@ public class AirportConfiguration : IEntityTypeConfiguration<Airport>
builder.HasKey(r => r.Id);
builder.Property(r => r.Id).ValueGeneratedNever()
.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();

View File

@ -1,4 +1,3 @@
using System;
using BuildingBlocks.Core.Model;
namespace Flight.Flights.Models;
@ -8,7 +7,6 @@ using Airports.ValueObjects;
using Features.CreatingFlight.V1;
using Features.DeletingFlight.V1;
using Features.UpdatingFlight.V1;
using global::Flight.Flights.Exceptions;
using global::Flight.Flights.ValueObjects;
public record Flight : Aggregate<FlightId>
@ -29,8 +27,6 @@ public record Flight : Aggregate<FlightId>
AirportId arriveAirportId, DurationMinutes durationMinutes, FlightDate flightDate, Enums.FlightStatus status,
Price price, bool isDeleted = false)
{
//SimpleFlightValidate(departureDate.Value, arriveDate.Value, flightDate.Value);
var flight = new Flight
{
Id = id,
@ -103,27 +99,4 @@ public record Flight : Aggregate<FlightId>
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;
}
}