Skip to content

Commit

Permalink
Resolve issues
Browse files Browse the repository at this point in the history
  • Loading branch information
amirhossein18121380 committed Jun 11, 2023
1 parent 343d0d6 commit 188a121
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 32 deletions.
4 changes: 0 additions & 4 deletions src/BuildingBlocks/BuildingBlocks.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -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" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public void Configure(EntityTypeBuilder<Airport> builder)
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();


Expand Down
27 changes: 0 additions & 27 deletions src/Services/Flight/src/Flight/Flights/Models/Flight.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using System;
using BuildingBlocks.Core.Model;

namespace Flight.Flights.Models;
Expand All @@ -8,7 +7,6 @@ namespace Flight.Flights.Models;
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>
Expand All @@ -29,8 +27,6 @@ public static Flight Create(FlightId id, FlightNumber flightNumber, AircraftId a
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,
Expand Down Expand Up @@ -103,27 +99,4 @@ public void Delete(FlightId id, FlightNumber flightNumber, AircraftId aircraftId

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;
}
}

0 comments on commit 188a121

Please sign in to comment.