diff --git a/deployments/docker-compose/docker-compose.yaml b/deployments/docker-compose/docker-compose.yaml
index 2151bb6..c89fa8a 100644
--- a/deployments/docker-compose/docker-compose.yaml
+++ b/deployments/docker-compose/docker-compose.yaml
@@ -16,11 +16,24 @@ services:
command:
- "postgres"
- "-c"
- - "wal_level=logical"
+ - "wal_level=logical"
networks:
- booking
+ #######################################################
+ # SqlServer
+ #######################################################
+ # sql:
+ # container_name: sql
+ # image: mcr.microsoft.com/mssql/server
+ # ports:
+ # - "1433:1433"
+ # environment:
+ # SA_PASSWORD: "Password@1234"
+ # ACCEPT_EULA: "Y"
+
+
#######################################################
# Rabbitmq
#######################################################
diff --git a/deployments/docker-compose/infrastracture.yaml b/deployments/docker-compose/infrastracture.yaml
index 24041dd..75f0748 100644
--- a/deployments/docker-compose/infrastracture.yaml
+++ b/deployments/docker-compose/infrastracture.yaml
@@ -30,10 +30,24 @@ services:
command:
- "postgres"
- "-c"
- - "wal_level=logical"
+ - "wal_level=logical"
networks:
- booking
+
+ #######################################################
+ # SqlServer
+ #######################################################
+ # sql:
+ # container_name: sql
+ # image: mcr.microsoft.com/mssql/server
+ # ports:
+ # - "1433:1433"
+ # environment:
+ # SA_PASSWORD: "Password@1234"
+ # ACCEPT_EULA: "Y"
+
+
#######################################################
# Jaeger
#######################################################
@@ -141,8 +155,6 @@ services:
ports:
- 6379:6379
-
-
networks:
booking:
diff --git a/src/BuildingBlocks/BuildingBlocks.csproj b/src/BuildingBlocks/BuildingBlocks.csproj
index 6449653..88a969d 100644
--- a/src/BuildingBlocks/BuildingBlocks.csproj
+++ b/src/BuildingBlocks/BuildingBlocks.csproj
@@ -77,6 +77,7 @@
+
@@ -99,6 +100,8 @@
+
+
@@ -141,10 +144,9 @@
-
+
-
-
+
@@ -154,6 +156,7 @@
+
diff --git a/src/BuildingBlocks/Core/Model/Aggregate.cs b/src/BuildingBlocks/Core/Model/Aggregate.cs
index 31865af..33238e7 100644
--- a/src/BuildingBlocks/Core/Model/Aggregate.cs
+++ b/src/BuildingBlocks/Core/Model/Aggregate.cs
@@ -2,9 +2,7 @@
namespace BuildingBlocks.Core.Model;
-public abstract record Aggregate : Aggregate;
-
-public abstract record Aggregate : Audit, IAggregate
+public abstract record Aggregate : Entity, IAggregate
{
private readonly List _domainEvents = new();
public IReadOnlyList DomainEvents => _domainEvents.AsReadOnly();
@@ -22,8 +20,4 @@ public abstract record Aggregate : Audit, IAggregate
return dequeuedEvents;
}
-
- public long Version { get; set; }
-
- public required TId Id { get; set; }
}
diff --git a/src/BuildingBlocks/Core/Model/IAudit.cs b/src/BuildingBlocks/Core/Model/Entity.cs
similarity index 59%
rename from src/BuildingBlocks/Core/Model/IAudit.cs
rename to src/BuildingBlocks/Core/Model/Entity.cs
index 7d463a7..50da2c8 100644
--- a/src/BuildingBlocks/Core/Model/IAudit.cs
+++ b/src/BuildingBlocks/Core/Model/Entity.cs
@@ -1,10 +1,12 @@
-namespace BuildingBlocks.Core.Model;
+namespace BuildingBlocks.Core.Model;
-public interface IAudit
+public abstract record Entity : IEntity
{
+ public T Id { get; set; }
public DateTime? CreatedAt { get; set; }
public long? CreatedBy { get; set; }
public DateTime? LastModified { get; set; }
public long? LastModifiedBy { get; set; }
public bool IsDeleted { get; set; }
+ public long Version { get; set; }
}
diff --git a/src/BuildingBlocks/Core/Model/IAggregate.cs b/src/BuildingBlocks/Core/Model/IAggregate.cs
index c79cc90..4f42b6d 100644
--- a/src/BuildingBlocks/Core/Model/IAggregate.cs
+++ b/src/BuildingBlocks/Core/Model/IAggregate.cs
@@ -2,18 +2,12 @@
namespace BuildingBlocks.Core.Model;
-public interface IAggregate : IAudit, IVersion
+public interface IAggregate : IAggregate, IEntity
+{
+}
+
+public interface IAggregate : IEntity
{
IReadOnlyList DomainEvents { get; }
IEvent[] ClearDomainEvents();
}
-
-public interface IAggregate : IAggregate
-{
- T Id { get; }
-}
-
-public interface IVersion
-{
- long Version { get; set; }
-}
diff --git a/src/BuildingBlocks/Core/Model/Audit.cs b/src/BuildingBlocks/Core/Model/IEntity.cs
similarity index 60%
rename from src/BuildingBlocks/Core/Model/Audit.cs
rename to src/BuildingBlocks/Core/Model/IEntity.cs
index eaf75ed..7182098 100644
--- a/src/BuildingBlocks/Core/Model/Audit.cs
+++ b/src/BuildingBlocks/Core/Model/IEntity.cs
@@ -1,6 +1,11 @@
-namespace BuildingBlocks.Core.Model;
+namespace BuildingBlocks.Core.Model;
-public abstract record Audit : IAudit
+public interface IEntity : IEntity
+{
+ public T Id { get; set; }
+}
+
+public interface IEntity: IVersion
{
public DateTime? CreatedAt { get; set; }
public long? CreatedBy { get; set; }
diff --git a/src/BuildingBlocks/Core/Model/IVersion.cs b/src/BuildingBlocks/Core/Model/IVersion.cs
new file mode 100644
index 0000000..3dc2a27
--- /dev/null
+++ b/src/BuildingBlocks/Core/Model/IVersion.cs
@@ -0,0 +1,6 @@
+namespace BuildingBlocks.Core.Model;
+
+public interface IVersion
+{
+ long Version { get; set; }
+}
diff --git a/src/BuildingBlocks/Core/Pagination/Extensions.cs b/src/BuildingBlocks/Core/Pagination/Extensions.cs
new file mode 100644
index 0000000..d5a94e4
--- /dev/null
+++ b/src/BuildingBlocks/Core/Pagination/Extensions.cs
@@ -0,0 +1,36 @@
+namespace BuildingBlocks.Core.Pagination;
+
+using Sieve.Models;
+using Sieve.Services;
+
+public static class Extensions
+{
+ public static async Task> ApplyPagingAsync(
+ this IQueryable queryable,
+ IPageRequest pageRequest,
+ ISieveProcessor sieveProcessor,
+ CancellationToken cancellationToken = default
+ )
+ where TEntity : class
+ {
+ var sieveModel = new SieveModel
+ {
+ PageSize = pageRequest.PageSize,
+ Page = pageRequest.PageNumber,
+ Sorts = pageRequest.SortOrder,
+ Filters = pageRequest.Filters
+ };
+
+ // https://github.com/Biarity/Sieve/issues/34#issuecomment-403817573
+ var result = sieveProcessor.Apply(sieveModel, queryable, applyPagination: false);
+ var total = result.Count();
+ result = sieveProcessor.Apply(sieveModel, queryable, applyFiltering: false,
+ applySorting: false); // Only applies pagination
+
+ var items = await result
+ .ToAsyncEnumerable()
+ .ToListAsync(cancellationToken: cancellationToken);
+
+ return PageList.Create(items.AsReadOnly(), pageRequest.PageNumber, pageRequest.PageSize, total);
+ }
+}
diff --git a/src/BuildingBlocks/Core/Pagination/IPageList.cs b/src/BuildingBlocks/Core/Pagination/IPageList.cs
new file mode 100644
index 0000000..f195244
--- /dev/null
+++ b/src/BuildingBlocks/Core/Pagination/IPageList.cs
@@ -0,0 +1,16 @@
+namespace BuildingBlocks.Core.Pagination;
+
+public interface IPageList
+ where T : class
+{
+ int CurrentPageSize { get; }
+ int CurrentStartIndex { get; }
+ int CurrentEndIndex { get; }
+ int TotalPages { get; }
+ bool HasPrevious { get; }
+ bool HasNext { get; }
+ IReadOnlyList Items { get; init; }
+ int TotalCount { get; init; }
+ int PageNumber { get; init; }
+ int PageSize { get; init; }
+}
diff --git a/src/BuildingBlocks/Core/Pagination/IPageQuery.cs b/src/BuildingBlocks/Core/Pagination/IPageQuery.cs
new file mode 100644
index 0000000..a8bc4b7
--- /dev/null
+++ b/src/BuildingBlocks/Core/Pagination/IPageQuery.cs
@@ -0,0 +1,6 @@
+namespace BuildingBlocks.Core.Pagination;
+
+using MediatR;
+
+public interface IPageQuery : IPageRequest, IRequest
+ where TResponse : class { }
diff --git a/src/BuildingBlocks/Core/Pagination/IPageRequest.cs b/src/BuildingBlocks/Core/Pagination/IPageRequest.cs
new file mode 100644
index 0000000..d904308
--- /dev/null
+++ b/src/BuildingBlocks/Core/Pagination/IPageRequest.cs
@@ -0,0 +1,9 @@
+namespace BuildingBlocks.Core.Pagination;
+
+public interface IPageRequest
+{
+ int PageNumber { get; init; }
+ int PageSize { get; init; }
+ string? Filters { get; init; }
+ string? SortOrder { get; init; }
+}
diff --git a/src/BuildingBlocks/Core/Pagination/PageList.cs b/src/BuildingBlocks/Core/Pagination/PageList.cs
new file mode 100644
index 0000000..44f90a3
--- /dev/null
+++ b/src/BuildingBlocks/Core/Pagination/PageList.cs
@@ -0,0 +1,19 @@
+namespace BuildingBlocks.Core.Pagination;
+
+public record PageList(IReadOnlyList Items, int PageNumber, int PageSize, int TotalCount) : IPageList
+ where T : class
+{
+ public int CurrentPageSize => Items.Count;
+ public int CurrentStartIndex => TotalCount == 0 ? 0 : ((PageNumber - 1) * PageSize) + 1;
+ public int CurrentEndIndex => TotalCount == 0 ? 0 : CurrentStartIndex + CurrentPageSize - 1;
+ public int TotalPages => (int)Math.Ceiling(TotalCount / (double)PageSize);
+ public bool HasPrevious => PageNumber > 1;
+ public bool HasNext => PageNumber < TotalPages;
+
+ public static PageList Empty => new(Enumerable.Empty().ToList(), 0, 0, 0);
+
+ public static PageList Create(IReadOnlyList items, int pageNumber, int pageSize, int totalItems)
+ {
+ return new PageList(items, pageNumber, pageSize, totalItems);
+ }
+}
diff --git a/src/BuildingBlocks/EFCore/EfTxBehavior.cs b/src/BuildingBlocks/EFCore/EfTxBehavior.cs
index 393fb5d..f58e7b1 100644
--- a/src/BuildingBlocks/EFCore/EfTxBehavior.cs
+++ b/src/BuildingBlocks/EFCore/EfTxBehavior.cs
@@ -50,12 +50,16 @@ public class EfTxBehavior : IPipelineBehavior),
typeof(TRequest).FullName);
- var domainEvents = _dbContextBase.GetDomainEvents();
+ while (true)
+ {
+ var domainEvents = _dbContextBase.GetDomainEvents();
- await _eventDispatcher.SendAsync(domainEvents.ToArray(), typeof(TRequest), cancellationToken);
+ if (domainEvents is null || !domainEvents.Any())
+ return response;
- await _dbContextBase.ExecuteTransactionalAsync(cancellationToken);
+ await _dbContextBase.ExecuteTransactionalAsync(cancellationToken);
- return response;
+ await _eventDispatcher.SendAsync(domainEvents.ToArray(), typeof(TRequest), cancellationToken);
+ }
}
}
diff --git a/src/BuildingBlocks/EFCore/Extensions.cs b/src/BuildingBlocks/EFCore/Extensions.cs
index bb3b0c0..2e4977f 100644
--- a/src/BuildingBlocks/EFCore/Extensions.cs
+++ b/src/BuildingBlocks/EFCore/Extensions.cs
@@ -66,7 +66,7 @@ public static class Extensions
{
Expression> filterExpr = e => !e.IsDeleted;
foreach (var mutableEntityType in modelBuilder.Model.GetEntityTypes()
- .Where(m => m.ClrType.IsAssignableTo(typeof(IAudit))))
+ .Where(m => m.ClrType.IsAssignableTo(typeof(IEntity))))
{
// modify expression to handle correct child type
var parameter = Expression.Parameter(mutableEntityType.ClrType);
diff --git a/src/BuildingBlocks/EventStoreDB/Events/AggregateEventSourcing.cs b/src/BuildingBlocks/EventStoreDB/Events/AggregateEventSourcing.cs
index cb4d5a9..d9578b1 100644
--- a/src/BuildingBlocks/EventStoreDB/Events/AggregateEventSourcing.cs
+++ b/src/BuildingBlocks/EventStoreDB/Events/AggregateEventSourcing.cs
@@ -3,7 +3,7 @@ using BuildingBlocks.Core.Model;
namespace BuildingBlocks.EventStoreDB.Events
{
- public abstract record AggregateEventSourcing : Audit, IAggregateEventSourcing
+ public abstract record AggregateEventSourcing : Entity, IAggregateEventSourcing
{
private readonly List _domainEvents = new();
public IReadOnlyList DomainEvents => _domainEvents.AsReadOnly();
@@ -23,10 +23,6 @@ namespace BuildingBlocks.EventStoreDB.Events
}
public virtual void When(object @event) { }
-
- public long Version { get; protected set; } = -1;
-
- public TId Id { get; protected set; }
}
}
diff --git a/src/BuildingBlocks/EventStoreDB/Events/IAggregateEventSourcing.cs b/src/BuildingBlocks/EventStoreDB/Events/IAggregateEventSourcing.cs
index d3f41b4..47a1af4 100644
--- a/src/BuildingBlocks/EventStoreDB/Events/IAggregateEventSourcing.cs
+++ b/src/BuildingBlocks/EventStoreDB/Events/IAggregateEventSourcing.cs
@@ -3,17 +3,15 @@ using BuildingBlocks.Core.Model;
namespace BuildingBlocks.EventStoreDB.Events
{
- public interface IAggregateEventSourcing : IProjection, IAudit
+ using Microsoft.FSharp.Control;
+
+ public interface IAggregateEventSourcing : IProjection, IEntity
{
IReadOnlyList DomainEvents { get; }
IDomainEvent[] ClearDomainEvents();
- long Version { get; }
}
- public interface IAggregateEventSourcing : IAggregateEventSourcing
+ public interface IAggregateEventSourcing : IAggregateEventSourcing, IEntity
{
- T Id { get; }
}
}
-
-
diff --git a/src/BuildingBlocks/TestBase/TestBase.cs b/src/BuildingBlocks/TestBase/TestBase.cs
index ef258e9..5b51f46 100644
--- a/src/BuildingBlocks/TestBase/TestBase.cs
+++ b/src/BuildingBlocks/TestBase/TestBase.cs
@@ -398,11 +398,17 @@ public class TestWriteFixture : TestFixture
});
}
- public Task FindAsync(Guid id)
- where T : class, IAudit
+ public Task FindAsync(TKey id)
+ where T : class, IEntity
{
return ExecuteDbContextAsync(db => db.Set().FindAsync(id).AsTask());
}
+
+ public Task FirstOrDefaultAsync()
+ where T : class, IEntity
+ {
+ return ExecuteDbContextAsync(db => db.Set().FirstOrDefaultAsync());
+ }
}
public class TestReadFixture : TestFixture
diff --git a/src/Services/Booking/src/Booking/Booking/Features/CreatingBook/Commands/V1/CreateBooking.cs b/src/Services/Booking/src/Booking/Booking/Features/CreatingBook/Commands/V1/CreateBooking.cs
index ac6aad4..7d64963 100644
--- a/src/Services/Booking/src/Booking/Booking/Features/CreatingBook/Commands/V1/CreateBooking.cs
+++ b/src/Services/Booking/src/Booking/Booking/Features/CreatingBook/Commands/V1/CreateBooking.cs
@@ -7,6 +7,7 @@ using BuildingBlocks.Core.Event;
using BuildingBlocks.Core.Model;
using BuildingBlocks.EventStoreDB.Repository;
using BuildingBlocks.Web;
+using Elasticsearch.Net;
using Exceptions;
using Flight;
using FluentValidation;
@@ -27,7 +28,7 @@ public record CreateBooking(Guid PassengerId, Guid FlightId, string Description)
public record CreateBookingResult(ulong Id);
-public record BookingCreatedDomainEvent(Guid Id, PassengerInfo PassengerInfo, Trip Trip) : Audit, IDomainEvent;
+public record BookingCreatedDomainEvent(Guid Id, PassengerInfo PassengerInfo, Trip Trip) : Entity, IDomainEvent;
public record CreateBookingRequestDto(Guid PassengerId, Guid FlightId, string Description);
diff --git a/src/Services/Flight/src/Flight/Flights/Features/CreatingFlight/V1/CreateFlight.cs b/src/Services/Flight/src/Flight/Flights/Features/CreatingFlight/V1/CreateFlight.cs
index bf1a8e4..b180f03 100644
--- a/src/Services/Flight/src/Flight/Flights/Features/CreatingFlight/V1/CreateFlight.cs
+++ b/src/Services/Flight/src/Flight/Flights/Features/CreatingFlight/V1/CreateFlight.cs
@@ -54,7 +54,7 @@ public class CreateFlightEndpoint : IMinimalEndpoint
return Results.CreatedAtRoute("GetFlightById", new { id = result.Id }, response);
})
- .RequireAuthorization()
+ // .RequireAuthorization()
.WithName("CreateFlight")
.WithApiVersionSet(builder.NewApiVersionSet("Flight").Build())
.Produces(StatusCodes.Status201Created)
@@ -68,7 +68,7 @@ public class CreateFlightEndpoint : IMinimalEndpoint
}
}
-internal class CreateFlightValidator : AbstractValidator
+public class CreateFlightValidator : AbstractValidator
{
public CreateFlightValidator()
{
diff --git a/src/Services/Flight/src/Flight/Identity/Consumers/RegisterNewUser/Consumes/V1/RegisterNewUserConsumerHandler.cs b/src/Services/Flight/src/Flight/Identity/Consumers/RegisterNewUser/V1/RegisterNewUserConsumerHandler.cs
similarity index 92%
rename from src/Services/Flight/src/Flight/Identity/Consumers/RegisterNewUser/Consumes/V1/RegisterNewUserConsumerHandler.cs
rename to src/Services/Flight/src/Flight/Identity/Consumers/RegisterNewUser/V1/RegisterNewUserConsumerHandler.cs
index 0325841..f533592 100644
--- a/src/Services/Flight/src/Flight/Identity/Consumers/RegisterNewUser/Consumes/V1/RegisterNewUserConsumerHandler.cs
+++ b/src/Services/Flight/src/Flight/Identity/Consumers/RegisterNewUser/V1/RegisterNewUserConsumerHandler.cs
@@ -1,3 +1,5 @@
+namespace Flight.Identity.Consumers.RegisterNewUser.V1;
+
using System.Threading.Tasks;
using BuildingBlocks.Contracts.EventBus.Messages;
using BuildingBlocks.Web;
@@ -6,8 +8,6 @@ using MassTransit;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
-namespace Flight.Identity.Consumers.RegisterNewUser.Consumes.V1;
-
public class RegisterNewUserConsumerHandler : IConsumer
{
private readonly AppOptions _options;
diff --git a/src/Services/Flight/tests/IntegrationTest/Flight/Features/DeleteFlightTests.cs b/src/Services/Flight/tests/IntegrationTest/Flight/Features/DeleteFlightTests.cs
index 2566e5d..c63ced1 100644
--- a/src/Services/Flight/tests/IntegrationTest/Flight/Features/DeleteFlightTests.cs
+++ b/src/Services/Flight/tests/IntegrationTest/Flight/Features/DeleteFlightTests.cs
@@ -10,8 +10,10 @@ using Xunit;
namespace Integration.Test.Flight.Features;
+using System;
using global::Flight.Data.Seed;
using global::Flight.Flights.Features.DeletingFlight.V1;
+using global::Flight.Flights.Models;
public class DeleteFlightTests : FlightIntegrationTestBase
{
@@ -24,7 +26,7 @@ public class DeleteFlightTests : FlightIntegrationTestBase
public async Task should_delete_flight_from_db()
{
// Arrange
- var flightEntity = await Fixture.FindAsync( InitialData.Flights.First().Id);
+ var flightEntity = await Fixture.FindAsync( InitialData.Flights.First().Id);
var command = new DeleteFlight(flightEntity.Id);
// Act
diff --git a/src/Services/Flight/tests/IntegrationTest/Flight/Features/UpdateFlightTests.cs b/src/Services/Flight/tests/IntegrationTest/Flight/Features/UpdateFlightTests.cs
index 20379e9..3f39958 100644
--- a/src/Services/Flight/tests/IntegrationTest/Flight/Features/UpdateFlightTests.cs
+++ b/src/Services/Flight/tests/IntegrationTest/Flight/Features/UpdateFlightTests.cs
@@ -9,9 +9,11 @@ using Xunit;
namespace Integration.Test.Flight.Features;
+using System;
using System.Linq;
using global::Flight.Data.Seed;
using global::Flight.Flights.Features.UpdatingFlight.V1;
+using global::Flight.Flights.Models;
public class UpdateFlightTests : FlightIntegrationTestBase
{
@@ -24,7 +26,7 @@ public class UpdateFlightTests : FlightIntegrationTestBase
public async Task should_update_flight_to_db_and_publish_message_to_broker()
{
// Arrange
- var flightEntity = await Fixture.FindAsync( InitialData.Flights.First().Id);
+ var flightEntity = await Fixture.FindAsync( InitialData.Flights.First().Id);
var command = new FakeUpdateFlightCommand(flightEntity).Generate();
// Act
diff --git a/src/Services/Flight/tests/UnitTest/Common/DbContextFactory.cs b/src/Services/Flight/tests/UnitTest/Common/DbContextFactory.cs
index cdfa957..97fccd7 100644
--- a/src/Services/Flight/tests/UnitTest/Common/DbContextFactory.cs
+++ b/src/Services/Flight/tests/UnitTest/Common/DbContextFactory.cs
@@ -5,80 +5,88 @@ using Flight.Flights.Enums;
using Flight.Seats.Enums;
using Microsoft.EntityFrameworkCore;
-namespace Unit.Test.Common
+namespace Unit.Test.Common;
+
+using MassTransit;
+
+public static class DbContextFactory
{
- using MassTransit;
+ private static readonly Guid _airportId1 = NewId.NextGuid();
+ private static readonly Guid _airportId2 = NewId.NextGuid();
+ private static readonly Guid _aircraft1 = NewId.NextGuid();
+ private static readonly Guid _aircraft2 = NewId.NextGuid();
+ private static readonly Guid _aircraft3 = NewId.NextGuid();
+ private static readonly Guid _flightId1 = NewId.NextGuid();
- public static class DbContextFactory
+ public static FlightDbContext Create()
{
- private static readonly Guid _airportId1 = NewId.NextGuid();
- private static readonly Guid _airportId2 = NewId.NextGuid();
- private static readonly Guid _aircraft1 = NewId.NextGuid();
- private static readonly Guid _aircraft2 = NewId.NextGuid();
- private static readonly Guid _aircraft3 = NewId.NextGuid();
- private static readonly Guid _flightId1 = NewId.NextGuid();
+ var options = new DbContextOptionsBuilder()
+ .UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString()).Options;
- public static FlightDbContext Create()
+ var context = new FlightDbContext(options, currentUserProvider: null);
+
+ // Seed our data
+ FlightDataSeeder(context);
+
+ return context;
+ }
+
+ private static void FlightDataSeeder(FlightDbContext context)
+ {
+ var airports = new List
{
- var options = new DbContextOptionsBuilder()
- .UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString()).Options;
+ global::Flight.Airports.Models.Airport.Create(_airportId1, "Lisbon International Airport", "LIS",
+ "12988"),
+ global::Flight.Airports.Models.Airport.Create(_airportId2, "Sao Paulo International Airport", "BRZ",
+ "11200")
+ };
- var context = new FlightDbContext(options, currentUserProvider: null);
+ context.Airports.AddRange(airports);
- // Seed our data
- FlightDataSeeder(context);
-
- return context;
- }
-
- private static void FlightDataSeeder(FlightDbContext context)
+ var aircrafts = new List
{
- var airports = new List
- {
- global::Flight.Airports.Models.Airport.Create(_airportId1, "Lisbon International Airport", "LIS", "12988"),
- global::Flight.Airports.Models.Airport.Create(_airportId2, "Sao Paulo International Airport", "BRZ", "11200")
- };
+ global::Flight.Aircrafts.Models.Aircraft.Create(_aircraft1, "Boeing 737", "B737", 2005),
+ global::Flight.Aircrafts.Models.Aircraft.Create(_aircraft2, "Airbus 300", "A300", 2000),
+ global::Flight.Aircrafts.Models.Aircraft.Create(_aircraft3, "Airbus 320", "A320", 2003)
+ };
- context.Airports.AddRange(airports);
+ context.Aircraft.AddRange(aircrafts);
- var aircrafts = new List
- {
- global::Flight.Aircrafts.Models.Aircraft.Create(_aircraft1, "Boeing 737", "B737", 2005),
- global::Flight.Aircrafts.Models.Aircraft.Create(_aircraft2, "Airbus 300", "A300", 2000),
- global::Flight.Aircrafts.Models.Aircraft.Create(_aircraft3, "Airbus 320", "A320", 2003)
- };
-
- context.Aircraft.AddRange(aircrafts);
-
- var flights = new List
- {
- global::Flight.Flights.Models.Flight.Create(_flightId1, "BD467", _aircraft1, _airportId1, new DateTime(2022, 1, 31, 12, 0, 0),
- new DateTime(2022, 1, 31, 14, 0, 0),
- _airportId2, 120m,
- new DateTime(2022, 1, 31), FlightStatus.Completed,
- 8000)
- };
- context.Flights.AddRange(flights);
-
- var seats = new List
- {
- global::Flight.Seats.Models.Seat.Create(NewId.NextGuid(), "12A", SeatType.Window, SeatClass.Economy, _flightId1),
- global::Flight.Seats.Models.Seat.Create(NewId.NextGuid(), "12B", SeatType.Window, SeatClass.Economy, _flightId1),
- global::Flight.Seats.Models.Seat.Create(NewId.NextGuid(), "12C", SeatType.Middle, SeatClass.Economy, _flightId1),
- global::Flight.Seats.Models.Seat.Create(NewId.NextGuid(), "12D", SeatType.Middle, SeatClass.Economy, _flightId1),
- global::Flight.Seats.Models.Seat.Create(NewId.NextGuid(), "12E", SeatType.Aisle, SeatClass.Economy, _flightId1),
- global::Flight.Seats.Models.Seat.Create(NewId.NextGuid(), "12F", SeatType.Aisle, SeatClass.Economy, _flightId1)
- };
-
- context.Seats.AddRange(seats);
-
- context.SaveChanges();
- }
-
- public static void Destroy(FlightDbContext context)
+ var flights = new List
{
- context.Database.EnsureDeleted();
- context.Dispose();
- }
+ global::Flight.Flights.Models.Flight.Create(_flightId1, "BD467", _aircraft1, _airportId1,
+ new DateTime(2022, 1, 31, 12, 0, 0),
+ new DateTime(2022, 1, 31, 14, 0, 0),
+ _airportId2, 120m,
+ new DateTime(2022, 1, 31), FlightStatus.Completed,
+ 8000)
+ };
+ context.Flights.AddRange(flights);
+
+ var seats = new List
+ {
+ global::Flight.Seats.Models.Seat.Create(NewId.NextGuid(), "12A", SeatType.Window, SeatClass.Economy,
+ _flightId1),
+ global::Flight.Seats.Models.Seat.Create(NewId.NextGuid(), "12B", SeatType.Window, SeatClass.Economy,
+ _flightId1),
+ global::Flight.Seats.Models.Seat.Create(NewId.NextGuid(), "12C", SeatType.Middle, SeatClass.Economy,
+ _flightId1),
+ global::Flight.Seats.Models.Seat.Create(NewId.NextGuid(), "12D", SeatType.Middle, SeatClass.Economy,
+ _flightId1),
+ global::Flight.Seats.Models.Seat.Create(NewId.NextGuid(), "12E", SeatType.Aisle, SeatClass.Economy,
+ _flightId1),
+ global::Flight.Seats.Models.Seat.Create(NewId.NextGuid(), "12F", SeatType.Aisle, SeatClass.Economy,
+ _flightId1)
+ };
+
+ context.Seats.AddRange(seats);
+
+ context.SaveChanges();
+ }
+
+ public static void Destroy(FlightDbContext context)
+ {
+ context.Database.EnsureDeleted();
+ context.Dispose();
}
}
diff --git a/src/Services/Flight/tests/UnitTest/Flight/Features/Domain/CreateFlightTests.cs b/src/Services/Flight/tests/UnitTest/Flight/Features/Domains/CreateFlightTests.cs
similarity index 94%
rename from src/Services/Flight/tests/UnitTest/Flight/Features/Domain/CreateFlightTests.cs
rename to src/Services/Flight/tests/UnitTest/Flight/Features/Domains/CreateFlightTests.cs
index 0729bf9..621d55a 100644
--- a/src/Services/Flight/tests/UnitTest/Flight/Features/Domain/CreateFlightTests.cs
+++ b/src/Services/Flight/tests/UnitTest/Flight/Features/Domains/CreateFlightTests.cs
@@ -1,4 +1,4 @@
-namespace Unit.Test.Flight.Features.Domain
+namespace Unit.Test.Flight.Features.Domains
{
using System.Linq;
using FluentAssertions;
diff --git a/src/Services/Flight/tests/UnitTest/Flight/Features/Domain/UpdateFlightTests.cs b/src/Services/Flight/tests/UnitTest/Flight/Features/Domains/UpdateFlightTests.cs
similarity index 95%
rename from src/Services/Flight/tests/UnitTest/Flight/Features/Domain/UpdateFlightTests.cs
rename to src/Services/Flight/tests/UnitTest/Flight/Features/Domains/UpdateFlightTests.cs
index 37e46fa..cd4f650 100644
--- a/src/Services/Flight/tests/UnitTest/Flight/Features/Domain/UpdateFlightTests.cs
+++ b/src/Services/Flight/tests/UnitTest/Flight/Features/Domains/UpdateFlightTests.cs
@@ -1,4 +1,4 @@
-namespace Unit.Test.Flight.Features.Domain;
+namespace Unit.Test.Flight.Features.Domains;
using System.Linq;
using FluentAssertions;
diff --git a/src/Services/Flight/tests/UnitTest/Flight/Features/Commands/CreateFlight/CreateFlightCommandHandlerTests.cs b/src/Services/Flight/tests/UnitTest/Flight/Features/Handlers/CreateFlight/CreateFlightCommandHandlerTests.cs
similarity index 92%
rename from src/Services/Flight/tests/UnitTest/Flight/Features/Commands/CreateFlight/CreateFlightCommandHandlerTests.cs
rename to src/Services/Flight/tests/UnitTest/Flight/Features/Handlers/CreateFlight/CreateFlightCommandHandlerTests.cs
index bf6ccf0..9786258 100644
--- a/src/Services/Flight/tests/UnitTest/Flight/Features/Commands/CreateFlight/CreateFlightCommandHandlerTests.cs
+++ b/src/Services/Flight/tests/UnitTest/Flight/Features/Handlers/CreateFlight/CreateFlightCommandHandlerTests.cs
@@ -1,13 +1,12 @@
-namespace Unit.Test.Flight.Features.Commands.CreateFlight;
+namespace Unit.Test.Flight.Features.Handlers.CreateFlight;
using System;
using System.Threading;
using System.Threading.Tasks;
using FluentAssertions;
-using global::Flight.Flights.Dtos;
using global::Flight.Flights.Features.CreatingFlight.V1;
-using Common;
-using Fakes;
+using Unit.Test.Common;
+using Unit.Test.Fakes;
using Xunit;
[Collection(nameof(UnitTestFixture))]
diff --git a/src/Services/Flight/tests/UnitTest/Flight/Features/Commands/CreateFlight/CreateFlightCommandValidatorTests.cs b/src/Services/Flight/tests/UnitTest/Flight/Features/Handlers/CreateFlight/CreateFlightCommandValidatorTests.cs
similarity index 94%
rename from src/Services/Flight/tests/UnitTest/Flight/Features/Commands/CreateFlight/CreateFlightCommandValidatorTests.cs
rename to src/Services/Flight/tests/UnitTest/Flight/Features/Handlers/CreateFlight/CreateFlightCommandValidatorTests.cs
index 50de43f..98b05a1 100644
--- a/src/Services/Flight/tests/UnitTest/Flight/Features/Commands/CreateFlight/CreateFlightCommandValidatorTests.cs
+++ b/src/Services/Flight/tests/UnitTest/Flight/Features/Handlers/CreateFlight/CreateFlightCommandValidatorTests.cs
@@ -1,4 +1,4 @@
-namespace Unit.Test.Flight.Features.Commands.CreateFlight;
+namespace Unit.Test.Flight.Features.Handlers.CreateFlight;
using FluentAssertions;
using FluentValidation.TestHelper;
diff --git a/src/Services/Identity/src/Identity/Data/IdentityContext.cs b/src/Services/Identity/src/Identity/Data/IdentityContext.cs
index 8dbf27f..3d2a132 100644
--- a/src/Services/Identity/src/Identity/Data/IdentityContext.cs
+++ b/src/Services/Identity/src/Identity/Data/IdentityContext.cs
@@ -63,7 +63,7 @@ public sealed class IdentityContext : IdentityDbContext GetDomainEvents()
{
var domainEntities = ChangeTracker
- .Entries()
+ .Entries()
.Where(x => x.Entity.DomainEvents.Any())
.Select(x => x.Entity)
.ToList();