diff --git a/booking.rest b/booking.rest
index 0140e30..319ae75 100644
--- a/booking.rest
+++ b/booking.rest
@@ -8,8 +8,8 @@
@booking-api=http://localhost:6010
@contentType = application/json
-@flightid = 1
-@passengerId = 1
+@flightid = "3c5c0000-97c6-fc34-2eb9-08db322230c9"
+@passengerId = "8c9c0000-97c6-fc34-2eb9-66db322230c9"
################################# Identity API #################################
@@ -70,7 +70,7 @@ authorization: bearer {{Authenticate.response.body.access_token}}
"seatNumber": "1255",
"type": 1,
"class": 1,
- "flightId": 1
+ "flightId": "3c5c0000-97c6-fc34-2eb9-08db322230c9"
}
###
@@ -83,7 +83,7 @@ Content-Type: application/json
authorization: bearer {{Authenticate.response.body.access_token}}
{
- "flightId": 1,
+ "flightId": "3c5c0000-97c6-fc34-2eb9-08db322230c9",
"seatNumber": "1255"
}
###
@@ -125,11 +125,11 @@ authorization: bearer {{Authenticate.response.body.access_token}}
{
"flightNumber": "12BB",
- "aircraftId": 1,
- "departureAirportId": 1,
+ "aircraftId": "3c5c0000-97c6-fc34-fcd3-08db322230c8",
+ "departureAirportId": "3c5c0000-97c6-fc34-a0cb-08db322230c8",
"departureDate": "2022-03-01T14:55:41.255Z",
"arriveDate": "2022-03-01T14:55:41.255Z",
- "arriveAirportId": 2,
+ "arriveAirportId": "3c5c0000-97c6-fc34-fc3c-08db322230c8",
"durationMinutes": 120,
"flightDate": "2022-03-01T14:55:41.255Z",
"status": 1,
@@ -148,11 +148,11 @@ authorization: bearer {{Authenticate.response.body.access_token}}
{
"id": 1,
"flightNumber": "BD467",
- "aircraftId": 1,
- "departureAirportId": 1,
+ "aircraftId": "3c5c0000-97c6-fc34-fcd3-08db322230c8",
+ "departureAirportId": "3c5c0000-97c6-fc34-a0cb-08db322230c8",
"departureDate": "2022-04-23T12:17:45.140Z",
"arriveDate": "2022-04-23T12:17:45.140Z",
- "arriveAirportId": 2,
+ "arriveAirportId": "3c5c0000-97c6-fc34-fc3c-08db322230c8",
"durationMinutes": 120,
"flightDate": "2022-04-23T12:17:45.140Z",
"status": 4,
@@ -250,8 +250,8 @@ Content-Type: application/json
authorization: bearer {{Authenticate.response.body.access_token}}
{
- "passengerId": 8765596234940416,
- "flightId": 1,
+ "passengerId": "8c9c0000-97c6-fc34-2eb9-66db322230c9",
+ "flightId": "3c5c0000-97c6-fc34-2eb9-08db322230c9",
"description": "I want to fly to iran"
}
###
diff --git a/src/BuildingBlocks/BuildingBlocks.csproj b/src/BuildingBlocks/BuildingBlocks.csproj
index 6ef8e41..5b7da12 100644
--- a/src/BuildingBlocks/BuildingBlocks.csproj
+++ b/src/BuildingBlocks/BuildingBlocks.csproj
@@ -18,7 +18,6 @@
-
diff --git a/src/BuildingBlocks/Contracts/EventBus.Messages/FlighContracts.cs b/src/BuildingBlocks/Contracts/EventBus.Messages/FlighContracts.cs
index 72b7a62..6d6dccf 100644
--- a/src/BuildingBlocks/Contracts/EventBus.Messages/FlighContracts.cs
+++ b/src/BuildingBlocks/Contracts/EventBus.Messages/FlighContracts.cs
@@ -2,10 +2,10 @@ using BuildingBlocks.Core.Event;
namespace BuildingBlocks.Contracts.EventBus.Messages;
-public record FlightCreated(long Id) : IIntegrationEvent;
-public record FlightUpdated(long Id) : IIntegrationEvent;
-public record FlightDeleted(long Id) : IIntegrationEvent;
-public record AircraftCreated(long Id) : IIntegrationEvent;
-public record AirportCreated(long Id) : IIntegrationEvent;
-public record SeatCreated(long Id) : IIntegrationEvent;
-public record SeatReserved(long Id) : IIntegrationEvent;
+public record FlightCreated(Guid Id) : IIntegrationEvent;
+public record FlightUpdated(Guid Id) : IIntegrationEvent;
+public record FlightDeleted(Guid Id) : IIntegrationEvent;
+public record AircraftCreated(Guid Id) : IIntegrationEvent;
+public record AirportCreated(Guid Id) : IIntegrationEvent;
+public record SeatCreated(Guid Id) : IIntegrationEvent;
+public record SeatReserved(Guid Id) : IIntegrationEvent;
diff --git a/src/BuildingBlocks/Contracts/EventBus.Messages/IdentityContracts.cs b/src/BuildingBlocks/Contracts/EventBus.Messages/IdentityContracts.cs
index c39cba5..f0af2b9 100644
--- a/src/BuildingBlocks/Contracts/EventBus.Messages/IdentityContracts.cs
+++ b/src/BuildingBlocks/Contracts/EventBus.Messages/IdentityContracts.cs
@@ -2,4 +2,4 @@ using BuildingBlocks.Core.Event;
namespace BuildingBlocks.Contracts.EventBus.Messages;
-public record UserCreated(long Id, string Name, string PassportNumber) : IIntegrationEvent;
+public record UserCreated(Guid Id, string Name, string PassportNumber) : IIntegrationEvent;
diff --git a/src/BuildingBlocks/Contracts/EventBus.Messages/PassengerContracts.cs b/src/BuildingBlocks/Contracts/EventBus.Messages/PassengerContracts.cs
index aadff7c..551620d 100644
--- a/src/BuildingBlocks/Contracts/EventBus.Messages/PassengerContracts.cs
+++ b/src/BuildingBlocks/Contracts/EventBus.Messages/PassengerContracts.cs
@@ -2,5 +2,5 @@ using BuildingBlocks.Core.Event;
namespace BuildingBlocks.Contracts.EventBus.Messages;
-public record PassengerRegistrationCompleted(long Id) : IIntegrationEvent;
-public record PassengerCreated(long Id) : IIntegrationEvent;
+public record PassengerRegistrationCompleted(Guid Id) : IIntegrationEvent;
+public record PassengerCreated(Guid Id) : IIntegrationEvent;
diff --git a/src/BuildingBlocks/Contracts/EventBus.Messages/ReservationContracts.cs b/src/BuildingBlocks/Contracts/EventBus.Messages/ReservationContracts.cs
index ca7bdfb..d32daf4 100644
--- a/src/BuildingBlocks/Contracts/EventBus.Messages/ReservationContracts.cs
+++ b/src/BuildingBlocks/Contracts/EventBus.Messages/ReservationContracts.cs
@@ -2,4 +2,4 @@ using BuildingBlocks.Core.Event;
namespace BuildingBlocks.Contracts.EventBus.Messages;
-public record BookingCreated(long Id) : IIntegrationEvent;
+public record BookingCreated(Guid Id) : IIntegrationEvent;
diff --git a/src/BuildingBlocks/Core/Event/IEvent.cs b/src/BuildingBlocks/Core/Event/IEvent.cs
index 9a00477..749c441 100644
--- a/src/BuildingBlocks/Core/Event/IEvent.cs
+++ b/src/BuildingBlocks/Core/Event/IEvent.cs
@@ -1,11 +1,12 @@
-using BuildingBlocks.IdsGenerator;
using MediatR;
namespace BuildingBlocks.Core.Event;
+using global::MassTransit;
+
public interface IEvent : INotification
{
- long EventId => SnowflakeIdGenerator.NewId();
+ Guid EventId => NewId.NextGuid();
public DateTime OccurredOn => DateTime.Now;
public string EventType => GetType().AssemblyQualifiedName;
}
diff --git a/src/BuildingBlocks/Core/Event/InternalCommand.cs b/src/BuildingBlocks/Core/Event/InternalCommand.cs
index b854545..b5ca942 100644
--- a/src/BuildingBlocks/Core/Event/InternalCommand.cs
+++ b/src/BuildingBlocks/Core/Event/InternalCommand.cs
@@ -1,5 +1,4 @@
using BuildingBlocks.Core.CQRS;
-using BuildingBlocks.IdsGenerator;
namespace BuildingBlocks.Core.Event;
diff --git a/src/BuildingBlocks/Core/Model/Aggregate.cs b/src/BuildingBlocks/Core/Model/Aggregate.cs
index 14697d5..f64caaf 100644
--- a/src/BuildingBlocks/Core/Model/Aggregate.cs
+++ b/src/BuildingBlocks/Core/Model/Aggregate.cs
@@ -1,32 +1,29 @@
using BuildingBlocks.Core.Event;
-namespace BuildingBlocks.Core.Model
+namespace BuildingBlocks.Core.Model;
+
+public abstract record Aggregate : Aggregate;
+
+public abstract record Aggregate : Audit, IAggregate
{
- public abstract record Aggregate : Aggregate
+ private readonly List _domainEvents = new();
+ public IReadOnlyList DomainEvents => _domainEvents.AsReadOnly();
+
+ public void AddDomainEvent(IDomainEvent domainEvent)
{
+ _domainEvents.Add(domainEvent);
}
- public abstract record Aggregate : Audit, IAggregate
+ public IEvent[] ClearDomainEvents()
{
- private readonly List _domainEvents = new();
- public IReadOnlyList DomainEvents => _domainEvents.AsReadOnly();
+ IEvent[] dequeuedEvents = _domainEvents.ToArray();
- public void AddDomainEvent(IDomainEvent domainEvent)
- {
- _domainEvents.Add(domainEvent);
- }
+ _domainEvents.Clear();
- public IEvent[] ClearDomainEvents()
- {
- IEvent[] dequeuedEvents = _domainEvents.ToArray();
-
- _domainEvents.Clear();
-
- return dequeuedEvents;
- }
-
- public long Version { get; set; }
-
- public TId Id { get; set; }
+ return dequeuedEvents;
}
+
+ public long Version { get; set; }
+
+ public TId Id { get; set; }
}
diff --git a/src/BuildingBlocks/EventStoreDB/Events/AggregateStreamExtensions.cs b/src/BuildingBlocks/EventStoreDB/Events/AggregateStreamExtensions.cs
index 03d93ec..34452d8 100644
--- a/src/BuildingBlocks/EventStoreDB/Events/AggregateStreamExtensions.cs
+++ b/src/BuildingBlocks/EventStoreDB/Events/AggregateStreamExtensions.cs
@@ -7,7 +7,7 @@ public static class AggregateStreamExtensions
{
public static async Task AggregateStream(
this EventStoreClient eventStore,
- long id,
+ Guid id,
CancellationToken cancellationToken,
ulong? fromVersion = null
) where T : class, IProjection
@@ -19,11 +19,13 @@ public static class AggregateStreamExtensions
cancellationToken: cancellationToken
);
- // TODO: consider adding extension method for the aggregation and deserialisation
+ // TODO: consider adding extension method for the aggregation and deserialization
var aggregate = (T)Activator.CreateInstance(typeof(T), true)!;
if (await readResult.ReadState == ReadState.StreamNotFound)
+ {
return null;
+ }
await foreach (var @event in readResult)
{
diff --git a/src/BuildingBlocks/EventStoreDB/Repository/EventStoreDBRepository.cs b/src/BuildingBlocks/EventStoreDB/Repository/EventStoreDBRepository.cs
index 8dee798..767e19a 100644
--- a/src/BuildingBlocks/EventStoreDB/Repository/EventStoreDBRepository.cs
+++ b/src/BuildingBlocks/EventStoreDB/Repository/EventStoreDBRepository.cs
@@ -4,9 +4,9 @@ using EventStore.Client;
namespace BuildingBlocks.EventStoreDB.Repository;
-public interface IEventStoreDBRepository where T : class, IAggregateEventSourcing
+public interface IEventStoreDBRepository where T : class, IAggregateEventSourcing
{
- Task Find(long id, CancellationToken cancellationToken);
+ Task Find(Guid id, CancellationToken cancellationToken);
Task Add(T aggregate, CancellationToken cancellationToken);
Task Update(T aggregate, long? expectedRevision = null,
@@ -15,7 +15,7 @@ public interface IEventStoreDBRepository where T : class, IAggregateEventSour
Task Delete(T aggregate, long? expectedRevision = null, CancellationToken cancellationToken = default);
}
-public class EventStoreDBRepository : IEventStoreDBRepository where T : class, IAggregateEventSourcing
+public class EventStoreDBRepository : IEventStoreDBRepository where T : class, IAggregateEventSourcing
{
private static readonly long _currentUserId;
private readonly EventStoreClient eventStore;
@@ -25,7 +25,7 @@ public class EventStoreDBRepository : IEventStoreDBRepository where T : cl
this.eventStore = eventStore ?? throw new ArgumentNullException(nameof(eventStore));
}
- public Task Find(long id, CancellationToken cancellationToken)
+ public Task Find(Guid id, CancellationToken cancellationToken)
{
return eventStore.AggregateStream(
id,
diff --git a/src/BuildingBlocks/EventStoreDB/Repository/RepositoryExtensions.cs b/src/BuildingBlocks/EventStoreDB/Repository/RepositoryExtensions.cs
index 66c7c9e..79ba271 100644
--- a/src/BuildingBlocks/EventStoreDB/Repository/RepositoryExtensions.cs
+++ b/src/BuildingBlocks/EventStoreDB/Repository/RepositoryExtensions.cs
@@ -7,9 +7,9 @@ public static class RepositoryExtensions
{
public static async Task Get(
this IEventStoreDBRepository repository,
- long id,
+ Guid id,
CancellationToken cancellationToken
- ) where T : class, IAggregateEventSourcing
+ ) where T : class, IAggregateEventSourcing
{
var entity = await repository.Find(id, cancellationToken);
@@ -18,11 +18,11 @@ public static class RepositoryExtensions
public static async Task GetAndUpdate(
this IEventStoreDBRepository repository,
- long id,
+ Guid id,
Action action,
long? expectedVersion = null,
CancellationToken cancellationToken = default
- ) where T : class, IAggregateEventSourcing
+ ) where T : class, IAggregateEventSourcing
{
var entity = await repository.Get(id, cancellationToken);
diff --git a/src/BuildingBlocks/Exception/AggregateNotFoundException.cs b/src/BuildingBlocks/Exception/AggregateNotFoundException.cs
index 1e6d015..aadaad6 100644
--- a/src/BuildingBlocks/Exception/AggregateNotFoundException.cs
+++ b/src/BuildingBlocks/Exception/AggregateNotFoundException.cs
@@ -2,11 +2,11 @@ namespace BuildingBlocks.Exception;
public class AggregateNotFoundException : System.Exception
{
- public AggregateNotFoundException(string typeName, long id) : base($"{typeName} with id '{id}' was not found")
+ public AggregateNotFoundException(string typeName, Guid id) : base($"{typeName} with id '{id}' was not found")
{
}
- public static AggregateNotFoundException For(long id)
+ public static AggregateNotFoundException For(Guid id)
{
return new AggregateNotFoundException(typeof(T).Name, id);
}
diff --git a/src/BuildingBlocks/IdsGenerator/SnowflakeIdGenerator.cs b/src/BuildingBlocks/IdsGenerator/SnowflakeIdGenerator.cs
deleted file mode 100644
index b2fd850..0000000
--- a/src/BuildingBlocks/IdsGenerator/SnowflakeIdGenerator.cs
+++ /dev/null
@@ -1,35 +0,0 @@
-using IdGen;
-
-namespace BuildingBlocks.IdsGenerator;
-
-// Ref: https://github.com/RobThree/IdGen
-// https://github.com/RobThree/IdGen/issues/34
-// https://www.callicoder.com/distributed-unique-id-sequence-number-generator/
-public static class SnowflakeIdGenerator
-{
- private static readonly IdGenerator Generator;
- static SnowflakeIdGenerator()
- {
- // Read `GENERATOR_ID` from .env file in service root folder or system environment variables
- var generatorId = DotNetEnv.Env.GetInt("GENERATOR_ID", 0);
-
- // Let's say we take current time as our epoch
- var epoch = DateTime.Now;
-
- // Create an ID with 45 bits for timestamp, 2 for generator-id
- // and 16 for sequence
- var structure = new IdStructure(45, 2, 16);
-
- // Prepare options
- var options = new IdGeneratorOptions(structure, new DefaultTimeSource(epoch));
-
- // Create an IdGenerator with it's generator-id set to 0, our custom epoch
- // and id-structure
- Generator = new IdGenerator(generatorId, options);
- }
-
- public static long NewId()
- {
- return Generator.CreateId();
- }
-}
diff --git a/src/BuildingBlocks/PersistMessageProcessor/Data/Migrations/20230122204943_initial.Designer.cs b/src/BuildingBlocks/PersistMessageProcessor/Data/Migrations/20230331173133_initial.Designer.cs
similarity index 93%
rename from src/BuildingBlocks/PersistMessageProcessor/Data/Migrations/20230122204943_initial.Designer.cs
rename to src/BuildingBlocks/PersistMessageProcessor/Data/Migrations/20230331173133_initial.Designer.cs
index c6730e2..1200bdf 100644
--- a/src/BuildingBlocks/PersistMessageProcessor/Data/Migrations/20230122204943_initial.Designer.cs
+++ b/src/BuildingBlocks/PersistMessageProcessor/Data/Migrations/20230331173133_initial.Designer.cs
@@ -12,7 +12,7 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
namespace BuildingBlocks.PersistMessageProcessor.Data.Migrations
{
[DbContext(typeof(PersistMessageDbContext))]
- [Migration("20230122204943_initial")]
+ [Migration("20230331173133_initial")]
partial class initial
{
///
@@ -20,15 +20,15 @@ namespace BuildingBlocks.PersistMessageProcessor.Data.Migrations
{
#pragma warning disable 612, 618
modelBuilder
- .HasAnnotation("ProductVersion", "7.0.1")
+ .HasAnnotation("ProductVersion", "7.0.2")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("BuildingBlocks.PersistMessageProcessor.PersistMessage", b =>
{
- b.Property("Id")
- .HasColumnType("bigint")
+ b.Property("Id")
+ .HasColumnType("uuid")
.HasColumnName("id");
b.Property("Created")
diff --git a/src/BuildingBlocks/PersistMessageProcessor/Data/Migrations/20230122204943_initial.cs b/src/BuildingBlocks/PersistMessageProcessor/Data/Migrations/20230331173133_initial.cs
similarity index 95%
rename from src/BuildingBlocks/PersistMessageProcessor/Data/Migrations/20230122204943_initial.cs
rename to src/BuildingBlocks/PersistMessageProcessor/Data/Migrations/20230331173133_initial.cs
index 47847cf..2518f08 100644
--- a/src/BuildingBlocks/PersistMessageProcessor/Data/Migrations/20230122204943_initial.cs
+++ b/src/BuildingBlocks/PersistMessageProcessor/Data/Migrations/20230331173133_initial.cs
@@ -15,7 +15,7 @@ namespace BuildingBlocks.PersistMessageProcessor.Data.Migrations
name: "persist_message",
columns: table => new
{
- id = table.Column(type: "bigint", nullable: false),
+ id = table.Column(type: "uuid", nullable: false),
datatype = table.Column(name: "data_type", type: "text", nullable: true),
data = table.Column(type: "text", nullable: true),
created = table.Column(type: "timestamp with time zone", nullable: false),
diff --git a/src/BuildingBlocks/PersistMessageProcessor/Data/Migrations/PersistMessageDbContextModelSnapshot.cs b/src/BuildingBlocks/PersistMessageProcessor/Data/Migrations/PersistMessageDbContextModelSnapshot.cs
index 2f55c12..dd237d0 100644
--- a/src/BuildingBlocks/PersistMessageProcessor/Data/Migrations/PersistMessageDbContextModelSnapshot.cs
+++ b/src/BuildingBlocks/PersistMessageProcessor/Data/Migrations/PersistMessageDbContextModelSnapshot.cs
@@ -17,15 +17,15 @@ namespace BuildingBlocks.PersistMessageProcessor.Data.Migrations
{
#pragma warning disable 612, 618
modelBuilder
- .HasAnnotation("ProductVersion", "7.0.1")
+ .HasAnnotation("ProductVersion", "7.0.2")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("BuildingBlocks.PersistMessageProcessor.PersistMessage", b =>
{
- b.Property("Id")
- .HasColumnType("bigint")
+ b.Property("Id")
+ .HasColumnType("uuid")
.HasColumnName("id");
b.Property("Created")
diff --git a/src/BuildingBlocks/PersistMessageProcessor/IPersistMessageProcessor.cs b/src/BuildingBlocks/PersistMessageProcessor/IPersistMessageProcessor.cs
index c1da1af..f83beda 100644
--- a/src/BuildingBlocks/PersistMessageProcessor/IPersistMessageProcessor.cs
+++ b/src/BuildingBlocks/PersistMessageProcessor/IPersistMessageProcessor.cs
@@ -15,7 +15,7 @@ public interface IPersistMessageProcessor
CancellationToken cancellationToken = default)
where TMessageEnvelope : MessageEnvelope;
- Task AddReceivedMessageAsync(
+ Task AddReceivedMessageAsync(
TMessageEnvelope messageEnvelope,
CancellationToken cancellationToken = default)
where TMessageEnvelope : MessageEnvelope;
@@ -30,14 +30,14 @@ public interface IPersistMessageProcessor
CancellationToken cancellationToken = default);
Task ExistMessageAsync(
- long messageId,
+ Guid messageId,
CancellationToken cancellationToken = default);
Task ProcessInboxAsync(
- long messageId,
+ Guid messageId,
CancellationToken cancellationToken = default);
- Task ProcessAsync(long messageId, MessageDeliveryType deliveryType, CancellationToken cancellationToken = default);
+ Task ProcessAsync(Guid messageId, MessageDeliveryType deliveryType, CancellationToken cancellationToken = default);
Task ProcessAllAsync(CancellationToken cancellationToken = default);
}
diff --git a/src/BuildingBlocks/PersistMessageProcessor/PersistMessage.cs b/src/BuildingBlocks/PersistMessageProcessor/PersistMessage.cs
index bd25d4e..42d0ca5 100644
--- a/src/BuildingBlocks/PersistMessageProcessor/PersistMessage.cs
+++ b/src/BuildingBlocks/PersistMessageProcessor/PersistMessage.cs
@@ -4,7 +4,7 @@ using Core.Model;
public class PersistMessage: IVersion
{
- public PersistMessage(long id, string dataType, string data, MessageDeliveryType deliveryType)
+ public PersistMessage(Guid id, string dataType, string data, MessageDeliveryType deliveryType)
{
Id = id;
DataType = dataType;
@@ -15,7 +15,7 @@ public class PersistMessage: IVersion
RetryCount = 0;
}
- public long Id { get; private set; }
+ public Guid Id { get; private set; }
public string DataType { get; private set; }
public string Data { get; private set; }
public DateTime Created { get; private set; }
diff --git a/src/BuildingBlocks/PersistMessageProcessor/PersistMessageProcessor.cs b/src/BuildingBlocks/PersistMessageProcessor/PersistMessageProcessor.cs
index 561e059..ff18f6e 100644
--- a/src/BuildingBlocks/PersistMessageProcessor/PersistMessageProcessor.cs
+++ b/src/BuildingBlocks/PersistMessageProcessor/PersistMessageProcessor.cs
@@ -2,7 +2,6 @@
using System.Text.Json;
using Ardalis.GuardClauses;
using BuildingBlocks.Core.Event;
-using BuildingBlocks.IdsGenerator;
using BuildingBlocks.Utils;
using MassTransit;
using MediatR;
@@ -40,7 +39,7 @@ public class PersistMessageProcessor : IPersistMessageProcessor
await SavePersistMessageAsync(messageEnvelope, MessageDeliveryType.Outbox, cancellationToken);
}
- public Task AddReceivedMessageAsync(TMessageEnvelope messageEnvelope,
+ public Task AddReceivedMessageAsync(TMessageEnvelope messageEnvelope,
CancellationToken cancellationToken = default) where TMessageEnvelope : MessageEnvelope
{
return SavePersistMessageAsync(messageEnvelope, MessageDeliveryType.Inbox, cancellationToken);
@@ -60,7 +59,7 @@ public class PersistMessageProcessor : IPersistMessageProcessor
.AsReadOnly();
}
- public Task ExistMessageAsync(long messageId, CancellationToken cancellationToken = default)
+ public Task ExistMessageAsync(Guid messageId, CancellationToken cancellationToken = default)
{
return _persistMessageDbContext.PersistMessages.FirstOrDefaultAsync(x =>
x.Id == messageId &&
@@ -70,7 +69,7 @@ public class PersistMessageProcessor : IPersistMessageProcessor
}
public async Task ProcessAsync(
- long messageId,
+ Guid messageId,
MessageDeliveryType deliveryType,
CancellationToken cancellationToken = default)
{
@@ -131,7 +130,7 @@ public class PersistMessageProcessor : IPersistMessageProcessor
}
}
- public async Task ProcessInboxAsync(long messageId, CancellationToken cancellationToken = default)
+ public async Task ProcessInboxAsync(Guid messageId, CancellationToken cancellationToken = default)
{
var message = await _persistMessageDbContext.PersistMessages.FirstOrDefaultAsync(
x => x.Id == messageId &&
@@ -191,18 +190,18 @@ public class PersistMessageProcessor : IPersistMessageProcessor
return true;
}
- private async Task SavePersistMessageAsync(
+ private async Task SavePersistMessageAsync(
MessageEnvelope messageEnvelope,
MessageDeliveryType deliveryType,
CancellationToken cancellationToken = default)
{
Guard.Against.Null(messageEnvelope.Message, nameof(messageEnvelope.Message));
- long id;
+ Guid id;
if (messageEnvelope.Message is IEvent message)
id = message.EventId;
else
- id = SnowflakeIdGenerator.NewId();
+ id = NewId.NextGuid();
await _persistMessageDbContext.PersistMessages.AddAsync(
new PersistMessage(
diff --git a/src/BuildingBlocks/TestBase/TestBase.cs b/src/BuildingBlocks/TestBase/TestBase.cs
index 93dbb38..ef258e9 100644
--- a/src/BuildingBlocks/TestBase/TestBase.cs
+++ b/src/BuildingBlocks/TestBase/TestBase.cs
@@ -398,7 +398,7 @@ public class TestWriteFixture : TestFixture
});
}
- public Task FindAsync(long id)
+ public Task FindAsync(Guid id)
where T : class, IAudit
{
return ExecuteDbContextAsync(db => db.Set().FindAsync(id).AsTask());
diff --git a/src/Services/Booking/src/Booking.Api/.env b/src/Services/Booking/src/Booking.Api/.env
deleted file mode 100644
index 467e2da..0000000
--- a/src/Services/Booking/src/Booking.Api/.env
+++ /dev/null
@@ -1 +0,0 @@
-GENERATOR_ID=4
diff --git a/src/Services/Booking/src/Booking/Booking/Dtos/CreateReservation.cs b/src/Services/Booking/src/Booking/Booking/Dtos/CreateReservation.cs
index f3392a8..56c4a89 100644
--- a/src/Services/Booking/src/Booking/Booking/Dtos/CreateReservation.cs
+++ b/src/Services/Booking/src/Booking/Booking/Dtos/CreateReservation.cs
@@ -1,4 +1,4 @@
namespace Booking.Booking.Dtos;
-public record BookingResponseDto(long Id, string Name, string FlightNumber, long AircraftId, decimal Price,
- DateTime FlightDate, string SeatNumber, long DepartureAirportId, long ArriveAirportId, string Description);
+public record BookingResponseDto(Guid Id, string Name, string FlightNumber, Guid AircraftId, decimal Price,
+ DateTime FlightDate, string SeatNumber, Guid DepartureAirportId, Guid ArriveAirportId, string Description);
diff --git a/src/Services/Booking/src/Booking/Booking/Features/CreatingBook/Commands/V1/BookingCreatedDomainEvent.cs b/src/Services/Booking/src/Booking/Booking/Features/CreatingBook/Commands/V1/BookingCreatedDomainEvent.cs
index e7ae19d..d919c60 100644
--- a/src/Services/Booking/src/Booking/Booking/Features/CreatingBook/Commands/V1/BookingCreatedDomainEvent.cs
+++ b/src/Services/Booking/src/Booking/Booking/Features/CreatingBook/Commands/V1/BookingCreatedDomainEvent.cs
@@ -4,4 +4,4 @@ using BuildingBlocks.Core.Event;
using BuildingBlocks.Core.Model;
using Models.ValueObjects;
-public record BookingCreatedDomainEvent(long Id, PassengerInfo PassengerInfo, Trip Trip) : Audit, IDomainEvent;
+public record BookingCreatedDomainEvent(Guid Id, PassengerInfo PassengerInfo, Trip Trip) : Audit, IDomainEvent;
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 01264fd..2e854d7 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
@@ -5,17 +5,17 @@ using BuildingBlocks.Core;
using BuildingBlocks.Core.CQRS;
using BuildingBlocks.Core.Event;
using BuildingBlocks.EventStoreDB.Repository;
-using BuildingBlocks.IdsGenerator;
using BuildingBlocks.Web;
using Exceptions;
using Flight;
using FluentValidation;
+using MassTransit;
using Models.ValueObjects;
using Passenger;
-public record CreateBooking(long PassengerId, long FlightId, string Description) : ICommand, IInternalCommand
+public record CreateBooking(Guid PassengerId, Guid FlightId, string Description) : ICommand, IInternalCommand
{
- public long Id { get; init; } = SnowflakeIdGenerator.NewId();
+ public Guid Id { get; init; } = NewId.NextGuid();
}
public record CreateBookingResult(ulong Id);
@@ -54,19 +54,17 @@ internal class CreateBookingCommandHandler : ICommandHandler
+public record Booking : AggregateEventSourcing
{
public Trip Trip { get; private set; }
public PassengerInfo PassengerInfo { get; private set; }
- public static Booking Create(long id, PassengerInfo passengerInfo, Trip trip, bool isDeleted = false, long? userId = null)
+ public static Booking Create(Guid id, PassengerInfo passengerInfo, Trip trip, bool isDeleted = false, long? userId = null)
{
var booking = new Booking { Id = id, Trip = trip, PassengerInfo = passengerInfo, IsDeleted = isDeleted };
diff --git a/src/Services/Booking/src/Booking/Booking/Models/Reads/BookingReadModel.cs b/src/Services/Booking/src/Booking/Booking/Models/BookingReadModel.cs
similarity index 51%
rename from src/Services/Booking/src/Booking/Booking/Models/Reads/BookingReadModel.cs
rename to src/Services/Booking/src/Booking/Booking/Models/BookingReadModel.cs
index 7ec381c..99b7e15 100644
--- a/src/Services/Booking/src/Booking/Booking/Models/Reads/BookingReadModel.cs
+++ b/src/Services/Booking/src/Booking/Booking/Models/BookingReadModel.cs
@@ -1,11 +1,11 @@
-using Booking.Booking.Models.ValueObjects;
+namespace Booking.Booking.Models;
-namespace Booking.Booking.Models.Reads;
+using ValueObjects;
public class BookingReadModel
{
- public long Id { get; init; }
- public long BookId { get; init; }
+ public Guid Id { get; init; }
+ public Guid BookId { get; init; }
public Trip Trip { get; init; }
public PassengerInfo PassengerInfo { get; init; }
public bool IsDeleted { get; init; }
diff --git a/src/Services/Booking/src/Booking/Booking/Models/ValueObjects/Trip.cs b/src/Services/Booking/src/Booking/Booking/Models/ValueObjects/Trip.cs
index 4a302e4..8d318fd 100644
--- a/src/Services/Booking/src/Booking/Booking/Models/ValueObjects/Trip.cs
+++ b/src/Services/Booking/src/Booking/Booking/Models/ValueObjects/Trip.cs
@@ -1,4 +1,4 @@
namespace Booking.Booking.Models.ValueObjects;
-public record Trip(string FlightNumber, long AircraftId, long DepartureAirportId, long ArriveAirportId,
+public record Trip(string FlightNumber, Guid AircraftId, Guid DepartureAirportId, Guid ArriveAirportId,
DateTime FlightDate, decimal Price, string Description, string SeatNumber);
diff --git a/src/Services/Booking/src/Booking/BookingProjection.cs b/src/Services/Booking/src/Booking/BookingProjection.cs
index fed0ade..68b8df3 100644
--- a/src/Services/Booking/src/Booking/BookingProjection.cs
+++ b/src/Services/Booking/src/Booking/BookingProjection.cs
@@ -1,8 +1,6 @@
-using Booking.Booking.Models.Reads;
using Booking.Data;
using BuildingBlocks.EventStoreDB.Events;
using BuildingBlocks.EventStoreDB.Projections;
-using BuildingBlocks.IdsGenerator;
using MediatR;
using MongoDB.Driver;
using MongoDB.Driver.Linq;
@@ -10,6 +8,8 @@ using MongoDB.Driver.Linq;
namespace Booking;
using Booking.Features.CreatingBook.Commands.V1;
+using Booking.Models;
+using MassTransit;
public class BookingProjection : IProjectionProcessor
{
@@ -41,7 +41,7 @@ public class BookingProjection : IProjectionProcessor
{
var bookingReadModel = new BookingReadModel
{
- Id = SnowflakeIdGenerator.NewId(),
+ Id = NewId.NextGuid(),
Trip = @event.Trip,
BookId = @event.Id,
PassengerInfo = @event.PassengerInfo,
diff --git a/src/Services/Booking/src/Booking/Data/BookingReadDbContext.cs b/src/Services/Booking/src/Booking/Data/BookingReadDbContext.cs
index 071244f..e2d48f5 100644
--- a/src/Services/Booking/src/Booking/Data/BookingReadDbContext.cs
+++ b/src/Services/Booking/src/Booking/Data/BookingReadDbContext.cs
@@ -1,11 +1,12 @@
-using Booking.Booking.Models.Reads;
-using BuildingBlocks.Mongo;
+using BuildingBlocks.Mongo;
using Humanizer;
using Microsoft.Extensions.Options;
using MongoDB.Driver;
namespace Booking.Data;
+using Booking.Models;
+
public class BookingReadDbContext : MongoDbContext
{
public BookingReadDbContext(IOptions options) : base(options)
diff --git a/src/Services/Booking/src/Booking/Extensions/Infrastructure/InfrastructureExtensions.cs b/src/Services/Booking/src/Booking/Extensions/Infrastructure/InfrastructureExtensions.cs
index 92de13d..c0aa996 100644
--- a/src/Services/Booking/src/Booking/Extensions/Infrastructure/InfrastructureExtensions.cs
+++ b/src/Services/Booking/src/Booking/Extensions/Infrastructure/InfrastructureExtensions.cs
@@ -33,9 +33,6 @@ public static class InfrastructureExtensions
var configuration = builder.Configuration;
var env = builder.Environment;
- // https://github.com/tonerdo/dotnet-env
- DotNetEnv.Env.TraversePath().Load();
-
builder.Services.AddScoped();
builder.Services.AddScoped();
builder.Services.AddScoped();
diff --git a/src/Services/Booking/src/Booking/GrpcClient/Protos/flight.proto b/src/Services/Booking/src/Booking/GrpcClient/Protos/flight.proto
index d70205c..aba77c4 100644
--- a/src/Services/Booking/src/Booking/GrpcClient/Protos/flight.proto
+++ b/src/Services/Booking/src/Booking/GrpcClient/Protos/flight.proto
@@ -5,51 +5,60 @@ import "google/protobuf/timestamp.proto";
service FlightGrpcService {
- rpc GetById (GetByIdRequest) returns (FlightResponse);
- rpc GetAvailableSeats (GetAvailableSeatsRequest) returns (ListSeatsResponse);
- rpc ReserveSeat (ReserveSeatRequest) returns (SeatsResponse);
+ rpc GetById (GetByIdRequest) returns (GetFlightByIdResult);
+ rpc GetAvailableSeats (GetAvailableSeatsRequest) returns (GetAvailableSeatsResult);
+ rpc ReserveSeat (ReserveSeatRequest) returns (ReserveSeatResult);
}
message GetByIdRequest {
- int64 Id = 1;
+ string Id = 1;
+}
+
+message GetFlightByIdResult{
+ FlightResponse FlightDto = 1;
+}
+
+message GetAvailableSeatsResult{
+repeated SeatDtoResponse SeatDtos = 1;
+}
+
+message ReserveSeatResult{
+ string Id = 1;
}
message FlightResponse {
- int64 Id = 1;
+ string Id = 1;
string FlightNumber = 2;
- int64 AircraftId = 3;
- int64 DepartureAirportId = 4;
+ string AircraftId = 3;
+ string DepartureAirportId = 4;
google.protobuf.Timestamp DepartureDate = 5;
google.protobuf.Timestamp ArriveDate = 6;
- int64 ArriveAirportId = 7;
+ string ArriveAirportId = 7;
double DurationMinutes = 8;
google.protobuf.Timestamp FlightDate = 9;
FlightStatus Status = 10;
double Price = 11;
- int64 FlightId = 12;
+ string FlightId = 12;
}
message GetAvailableSeatsRequest {
- int64 FlightId = 1;
+ string FlightId = 1;
}
-message SeatsResponse {
- int64 Id = 1;
+message SeatDtoResponse {
+ string Id = 1;
string SeatNumber = 2;
SeatType Type = 3;
SeatClass Class = 4;
- int64 FlightId = 5;
+ string FlightId = 5;
}
message ReserveSeatRequest {
- int64 FlightId = 1;
+ string FlightId = 1;
string SeatNumber = 2;
}
-message ListSeatsResponse {
- repeated SeatsResponse items = 1;
-}
enum FlightStatus {
FLIGHT_STATUS_UNKNOWN = 0;
diff --git a/src/Services/Booking/src/Booking/GrpcClient/Protos/passenger.proto b/src/Services/Booking/src/Booking/GrpcClient/Protos/passenger.proto
index dc63f56..bb98c29 100644
--- a/src/Services/Booking/src/Booking/GrpcClient/Protos/passenger.proto
+++ b/src/Services/Booking/src/Booking/GrpcClient/Protos/passenger.proto
@@ -4,15 +4,19 @@ package passenger;
service PassengerGrpcService {
- rpc GetById (GetByIdRequest) returns (PassengerResponse);
+ rpc GetById (GetByIdRequest) returns (GetPassengerByIdResult);
}
message GetByIdRequest {
- int64 Id = 1;
+ string Id = 1;
+}
+
+message GetPassengerByIdResult {
+ PassengerResponse PassengerDto = 1;
}
message PassengerResponse {
- int64 Id = 1;
+ string Id = 1;
string Name = 2;
string PassportNumber = 3;
PassengerType PassengerType = 4;
diff --git a/src/Services/Booking/tests/IntegrationTest/Booking/Features/CreateBookingTests.cs b/src/Services/Booking/tests/IntegrationTest/Booking/Features/CreateBookingTests.cs
index d779ae2..15aacbf 100644
--- a/src/Services/Booking/tests/IntegrationTest/Booking/Features/CreateBookingTests.cs
+++ b/src/Services/Booking/tests/IntegrationTest/Booking/Features/CreateBookingTests.cs
@@ -1,5 +1,4 @@
-using System.Linq;
-using System.Threading.Tasks;
+using System.Threading.Tasks;
using Booking.Api;
using Booking.Data;
using BuildingBlocks.Contracts.EventBus.Messages;
@@ -54,7 +53,7 @@ namespace Integration.Test.Booking.Features
var mockPassenger = Substitute.For();
mockPassenger.GetByIdAsync(Arg.Any())
- .Returns(TestCalls.AsyncUnaryCall(Task.FromResult(new FakePassengerResponse().Generate()),
+ .Returns(TestCalls.AsyncUnaryCall(Task.FromResult(FakePassengerResponse.Generate()),
Task.FromResult(new Metadata()), () => Status.DefaultSuccess, () => new Metadata(), () => { }));
return mockPassenger;
@@ -68,15 +67,15 @@ namespace Integration.Test.Booking.Features
var mockFlight = Substitute.For();
mockFlight.GetByIdAsync(Arg.Any())
- .Returns(TestCalls.AsyncUnaryCall(Task.FromResult(new FakeFlightResponse().Generate()),
+ .Returns(TestCalls.AsyncUnaryCall(Task.FromResult(FakeFlightResponse.Generate()),
Task.FromResult(new Metadata()), () => Status.DefaultSuccess, () => new Metadata(), () => { }));
mockFlight.GetAvailableSeatsAsync(Arg.Any())
- .Returns(TestCalls.AsyncUnaryCall(Task.FromResult(FakeSeatsResponse.Generate()),
+ .Returns(TestCalls.AsyncUnaryCall(Task.FromResult(FakeGetAvailableSeatsResponse.Generate()),
Task.FromResult(new Metadata()), () => Status.DefaultSuccess, () => new Metadata(), () => { }));
mockFlight.ReserveSeatAsync(Arg.Any())
- .Returns(TestCalls.AsyncUnaryCall(Task.FromResult(FakeSeatsResponse.Generate()?.Items?.First()),
+ .Returns(TestCalls.AsyncUnaryCall(Task.FromResult(FakeReserveSeatResponse.Generate()),
Task.FromResult(new Metadata()), () => Status.DefaultSuccess, () => new Metadata(), () => { }));
return mockFlight;
diff --git a/src/Services/Booking/tests/IntegrationTest/Fakes/FakeCreateBookingCommand.cs b/src/Services/Booking/tests/IntegrationTest/Fakes/FakeCreateBookingCommand.cs
index 3961db5..39f3846 100644
--- a/src/Services/Booking/tests/IntegrationTest/Fakes/FakeCreateBookingCommand.cs
+++ b/src/Services/Booking/tests/IntegrationTest/Fakes/FakeCreateBookingCommand.cs
@@ -1,16 +1,17 @@
using AutoBogus;
-using BuildingBlocks.IdsGenerator;
namespace Integration.Test.Fakes;
+using System;
using global::Booking.Booking.Features.CreatingBook.Commands.V1;
+using MassTransit;
public sealed class FakeCreateBookingCommand : AutoFaker
{
public FakeCreateBookingCommand()
{
- RuleFor(r => r.Id, _ => SnowflakeIdGenerator.NewId());
- RuleFor(r => r.FlightId, _ => 1);
- RuleFor(r => r.PassengerId, _ => 1);
+ RuleFor(r => r.Id, _ => NewId.NextGuid());
+ RuleFor(r => r.FlightId, _ => new Guid("3c5c0000-97c6-fc34-2eb9-08db322230c9"));
+ RuleFor(r => r.PassengerId, _ => new Guid("4c5c8888-97c6-fc34-2eb9-18db322230c1"));
}
}
diff --git a/src/Services/Booking/tests/IntegrationTest/Fakes/FakeFlightResponse.cs b/src/Services/Booking/tests/IntegrationTest/Fakes/FakeFlightResponse.cs
index 6e309c2..9a44330 100644
--- a/src/Services/Booking/tests/IntegrationTest/Fakes/FakeFlightResponse.cs
+++ b/src/Services/Booking/tests/IntegrationTest/Fakes/FakeFlightResponse.cs
@@ -5,19 +5,27 @@ using Google.Protobuf.WellKnownTypes;
namespace Integration.Test.Fakes;
-public class FakeFlightResponse : AutoFaker
+public static class FakeFlightResponse
{
- public FakeFlightResponse()
+ public static GetFlightByIdResult Generate()
{
- RuleFor(r => r.Id, _ => 1);
- RuleFor(r => r.Price, _ => 100);
- RuleFor(r => r.Status, _ => FlightStatus.Completed);
- RuleFor(r => r.AircraftId, _ => 1);
- RuleFor(r => r.ArriveAirportId, _ => 1);
- RuleFor(r => r.ArriveDate, _ => DateTime.SpecifyKind(DateTime.Now, DateTimeKind.Utc).ToTimestamp());
- RuleFor(r => r.DepartureDate, _ => DateTime.SpecifyKind(DateTime.Now, DateTimeKind.Utc).ToTimestamp());
- RuleFor(r => r.FlightDate, _ => DateTime.SpecifyKind(DateTime.Now, DateTimeKind.Utc).ToTimestamp());
- RuleFor(r => r.FlightNumber, r => r.Random.Number(1000, 2000).ToString());
- RuleFor(r => r.DepartureAirportId, _ => 2);
+ var flightMock = new GetFlightByIdResult
+ {
+ FlightDto = new FlightResponse
+ {
+ Id = new Guid("3c5c0000-97c6-fc34-2eb9-08db322230c9").ToString(),
+ Price = 100,
+ Status = FlightStatus.Completed,
+ AircraftId = new Guid("3c5c0000-97c6-fc34-fcd3-08db322230c8").ToString(),
+ ArriveAirportId = new Guid("3c5c0000-97c6-fc34-a0cb-08db322230c8").ToString(),
+ ArriveDate = DateTime.SpecifyKind(DateTime.Now, DateTimeKind.Utc).ToTimestamp(),
+ DepartureDate = DateTime.SpecifyKind(DateTime.Now, DateTimeKind.Utc).ToTimestamp(),
+ FlightDate = DateTime.SpecifyKind(DateTime.Now, DateTimeKind.Utc).ToTimestamp(),
+ FlightNumber = "1500B",
+ DepartureAirportId = new Guid("3c5c0000-97c6-fc34-fc3c-08db322230c8").ToString()
+ }
+ };
+
+ return flightMock;
}
}
diff --git a/src/Services/Booking/tests/IntegrationTest/Fakes/FakeGetAvailableSeatsResponse.cs b/src/Services/Booking/tests/IntegrationTest/Fakes/FakeGetAvailableSeatsResponse.cs
new file mode 100644
index 0000000..205a45c
--- /dev/null
+++ b/src/Services/Booking/tests/IntegrationTest/Fakes/FakeGetAvailableSeatsResponse.cs
@@ -0,0 +1,36 @@
+using System.Collections.Generic;
+using Flight;
+
+namespace Integration.Test.Fakes;
+
+using System;
+using MassTransit;
+
+public static class FakeGetAvailableSeatsResponse
+{
+ public static GetAvailableSeatsResult Generate()
+ {
+ var result = new GetAvailableSeatsResult();
+ result.SeatDtos.AddRange(new List
+ {
+ new SeatDtoResponse()
+ {
+ FlightId = new Guid("3c5c0000-97c6-fc34-2eb9-08db322230c9").ToString(),
+ Class = SeatClass.Economy,
+ Type = SeatType.Aisle,
+ SeatNumber = "33F",
+ Id = NewId.NextGuid().ToString()
+ },
+ new SeatDtoResponse()
+ {
+ FlightId = new Guid("3c5c0000-97c6-fc34-2eb9-08db322230c9").ToString(),
+ Class = SeatClass.Economy,
+ Type = SeatType.Window,
+ SeatNumber = "22D",
+ Id = NewId.NextGuid().ToString()
+ }
+ });
+
+ return result;
+ }
+}
diff --git a/src/Services/Booking/tests/IntegrationTest/Fakes/FakePassengerResponse.cs b/src/Services/Booking/tests/IntegrationTest/Fakes/FakePassengerResponse.cs
index a525e8a..31cbd98 100644
--- a/src/Services/Booking/tests/IntegrationTest/Fakes/FakePassengerResponse.cs
+++ b/src/Services/Booking/tests/IntegrationTest/Fakes/FakePassengerResponse.cs
@@ -1,13 +1,22 @@
-using AutoBogus;
-using BuildingBlocks.IdsGenerator;
+namespace Integration.Test.Fakes;
+
+using MassTransit;
using Passenger;
-namespace Integration.Test.Fakes;
-
-public class FakePassengerResponse : AutoFaker
+public static class FakePassengerResponse
{
- public FakePassengerResponse()
+ public static GetPassengerByIdResult Generate()
{
- RuleFor(r => r.Id, _ => SnowflakeIdGenerator.NewId());
+ var result = new GetPassengerByIdResult
+ {
+ PassengerDto = new PassengerResponse()
+ {
+ Id = NewId.NextGuid().ToString(),
+ Name = "Test",
+ PassportNumber = "121618"
+ }
+ };
+
+ return result;
}
}
diff --git a/src/Services/Booking/tests/IntegrationTest/Fakes/FakeReserveSeatResponse.cs b/src/Services/Booking/tests/IntegrationTest/Fakes/FakeReserveSeatResponse.cs
new file mode 100644
index 0000000..ea69f5c
--- /dev/null
+++ b/src/Services/Booking/tests/IntegrationTest/Fakes/FakeReserveSeatResponse.cs
@@ -0,0 +1,14 @@
+namespace Integration.Test.Fakes;
+using Flight;
+using MassTransit;
+
+public static class FakeReserveSeatResponse
+{
+ public static ReserveSeatResult Generate()
+ {
+ var result = new ReserveSeatResult();
+ result.Id = NewId.NextGuid().ToString();
+
+ return result;
+ }
+}
diff --git a/src/Services/Booking/tests/IntegrationTest/Fakes/FakeSeatsResponsecs.cs b/src/Services/Booking/tests/IntegrationTest/Fakes/FakeSeatsResponsecs.cs
deleted file mode 100644
index 6fbd781..0000000
--- a/src/Services/Booking/tests/IntegrationTest/Fakes/FakeSeatsResponsecs.cs
+++ /dev/null
@@ -1,33 +0,0 @@
-using System.Collections.Generic;
-using Flight;
-
-namespace Integration.Test.Fakes;
-
-public static class FakeSeatsResponse
-{
- public static ListSeatsResponse Generate()
- {
- var result = new ListSeatsResponse();
- result.Items.AddRange(new List
- {
- new SeatsResponse()
- {
- FlightId = 1,
- Class = SeatClass.Economy,
- Type = SeatType.Aisle,
- SeatNumber = "33F",
- Id = 1
- },
- new SeatsResponse()
- {
- FlightId = 1,
- Class = SeatClass.Economy,
- Type = SeatType.Window,
- SeatNumber = "22D",
- Id = 2
- }
- });
-
- return result;
- }
-}
diff --git a/src/Services/Flight/src/Flight.Api/.env b/src/Services/Flight/src/Flight.Api/.env
deleted file mode 100644
index 2e1ed1b..0000000
--- a/src/Services/Flight/src/Flight.Api/.env
+++ /dev/null
@@ -1 +0,0 @@
-GENERATOR_ID=1
diff --git a/src/Services/Flight/src/Flight/Aircrafts/Features/AircraftMappings.cs b/src/Services/Flight/src/Flight/Aircrafts/Features/AircraftMappings.cs
index 0da501b..9776895 100644
--- a/src/Services/Flight/src/Flight/Aircrafts/Features/AircraftMappings.cs
+++ b/src/Services/Flight/src/Flight/Aircrafts/Features/AircraftMappings.cs
@@ -1,21 +1,21 @@
-using BuildingBlocks.IdsGenerator;
-using Flight.Aircrafts.Models;
+using Flight.Aircrafts.Models;
using Mapster;
namespace Flight.Aircrafts.Features;
using CreatingAircraft.V1;
+using MassTransit;
public class AircraftMappings : IRegister
{
public void Register(TypeAdapterConfig config)
{
config.NewConfig()
- .Map(d => d.Id, s => SnowflakeIdGenerator.NewId())
+ .Map(d => d.Id, s => NewId.NextGuid())
.Map(d => d.AircraftId, s => s.Id);
config.NewConfig()
- .Map(d => d.Id, s => SnowflakeIdGenerator.NewId())
+ .Map(d => d.Id, s => NewId.NextGuid())
.Map(d => d.AircraftId, s => s.Id);
config.NewConfig()
diff --git a/src/Services/Flight/src/Flight/Aircrafts/Features/CreatingAircraft/V1/AircraftCreatedDomainEvent.cs b/src/Services/Flight/src/Flight/Aircrafts/Features/CreatingAircraft/V1/AircraftCreatedDomainEvent.cs
index f9c7bac..d296895 100644
--- a/src/Services/Flight/src/Flight/Aircrafts/Features/CreatingAircraft/V1/AircraftCreatedDomainEvent.cs
+++ b/src/Services/Flight/src/Flight/Aircrafts/Features/CreatingAircraft/V1/AircraftCreatedDomainEvent.cs
@@ -1,5 +1,6 @@
namespace Flight.Aircrafts.Features.CreatingAircraft.V1;
+using System;
using BuildingBlocks.Core.Event;
-public record AircraftCreatedDomainEvent(long Id, string Name, string Model, int ManufacturingYear, bool IsDeleted) : IDomainEvent;
+public record AircraftCreatedDomainEvent(Guid Id, string Name, string Model, int ManufacturingYear, bool IsDeleted) : IDomainEvent;
diff --git a/src/Services/Flight/src/Flight/Aircrafts/Features/CreatingAircraft/V1/CreateAircraft.cs b/src/Services/Flight/src/Flight/Aircrafts/Features/CreatingAircraft/V1/CreateAircraft.cs
index 64fa423..f06e33f 100644
--- a/src/Services/Flight/src/Flight/Aircrafts/Features/CreatingAircraft/V1/CreateAircraft.cs
+++ b/src/Services/Flight/src/Flight/Aircrafts/Features/CreatingAircraft/V1/CreateAircraft.cs
@@ -1,26 +1,25 @@
namespace Flight.Aircrafts.Features.CreatingAircraft.V1;
+using System;
using System.Threading;
using System.Threading.Tasks;
using Ardalis.GuardClauses;
using BuildingBlocks.Core.CQRS;
using BuildingBlocks.Core.Event;
-using BuildingBlocks.IdsGenerator;
using Exceptions;
-using Flight.Aircrafts.Dtos;
-using Flight.Aircrafts.Models;
-using Flight.Data;
+using Models;
+using Data;
using FluentValidation;
-using MapsterMapper;
+using MassTransit;
using MediatR;
using Microsoft.EntityFrameworkCore;
public record CreateAircraft(string Name, string Model, int ManufacturingYear) : ICommand, IInternalCommand
{
- public long Id { get; init; } = SnowflakeIdGenerator.NewId();
+ public Guid Id { get; init; } = NewId.NextGuid();
}
-public record CreateAircraftResult(long Id);
+public record CreateAircraftResult(Guid Id);
internal class CreateAircraftValidator : AbstractValidator
{
diff --git a/src/Services/Flight/src/Flight/Aircrafts/Features/CreatingAircraft/V1/CreateAircraftEndpoint.cs b/src/Services/Flight/src/Flight/Aircrafts/Features/CreatingAircraft/V1/CreateAircraftEndpoint.cs
index 3a1fe44..57abf33 100644
--- a/src/Services/Flight/src/Flight/Aircrafts/Features/CreatingAircraft/V1/CreateAircraftEndpoint.cs
+++ b/src/Services/Flight/src/Flight/Aircrafts/Features/CreatingAircraft/V1/CreateAircraftEndpoint.cs
@@ -1,5 +1,6 @@
namespace Flight.Aircrafts.Features.CreatingAircraft.V1;
+using System;
using System.Threading;
using System.Threading.Tasks;
using BuildingBlocks.Web;
@@ -11,7 +12,7 @@ using Microsoft.AspNetCore.Routing;
using Swashbuckle.AspNetCore.Annotations;
public record CreateAircraftRequestDto(string Name, string Model, int ManufacturingYear);
-public record CreateAircraftResponseDto(long Id);
+public record CreateAircraftResponseDto(Guid Id);
public class CreateAircraftEndpoint : IMinimalEndpoint
{
diff --git a/src/Services/Flight/src/Flight/Aircrafts/Features/CreatingAircraft/V1/CreateAircraftMongo.cs b/src/Services/Flight/src/Flight/Aircrafts/Features/CreatingAircraft/V1/CreateAircraftMongo.cs
index 845bd75..dcb5003 100644
--- a/src/Services/Flight/src/Flight/Aircrafts/Features/CreatingAircraft/V1/CreateAircraftMongo.cs
+++ b/src/Services/Flight/src/Flight/Aircrafts/Features/CreatingAircraft/V1/CreateAircraftMongo.cs
@@ -1,5 +1,6 @@
namespace Flight.Aircrafts.Features.CreatingAircraft.V1;
+using System;
using System.Threading;
using System.Threading.Tasks;
using Ardalis.GuardClauses;
@@ -13,7 +14,7 @@ using MediatR;
using MongoDB.Driver;
using MongoDB.Driver.Linq;
-public record CreateAircraftMongo(long Id, string Name, string Model, int ManufacturingYear, bool IsDeleted) : InternalCommand;
+public record CreateAircraftMongo(Guid Id, string Name, string Model, int ManufacturingYear, bool IsDeleted) : InternalCommand;
public class CreateAircraftMongoHandler : ICommandHandler
{
diff --git a/src/Services/Flight/src/Flight/Aircrafts/Models/Aircraft.cs b/src/Services/Flight/src/Flight/Aircrafts/Models/Aircraft.cs
index 2608f0a..6ac88dd 100644
--- a/src/Services/Flight/src/Flight/Aircrafts/Models/Aircraft.cs
+++ b/src/Services/Flight/src/Flight/Aircrafts/Models/Aircraft.cs
@@ -2,15 +2,16 @@ using BuildingBlocks.Core.Model;
namespace Flight.Aircrafts.Models;
+using System;
using Features.CreatingAircraft.V1;
-public record Aircraft : Aggregate
+public record Aircraft : Aggregate
{
public string Name { get; private set; }
public string Model { get; private set; }
public int ManufacturingYear { get; private set; }
- public static Aircraft Create(long id, string name, string model, int manufacturingYear, bool isDeleted = false)
+ public static Aircraft Create(Guid id, string name, string model, int manufacturingYear, bool isDeleted = false)
{
var aircraft = new Aircraft
{
diff --git a/src/Services/Flight/src/Flight/Aircrafts/Models/AircraftReadModel.cs b/src/Services/Flight/src/Flight/Aircrafts/Models/AircraftReadModel.cs
index 2f52435..bdca7f0 100644
--- a/src/Services/Flight/src/Flight/Aircrafts/Models/AircraftReadModel.cs
+++ b/src/Services/Flight/src/Flight/Aircrafts/Models/AircraftReadModel.cs
@@ -1,9 +1,11 @@
namespace Flight.Aircrafts.Models;
+using System;
+
public class AircraftReadModel
{
- public long Id { get; init; }
- public long AircraftId { get; init; }
+ public Guid Id { get; init; }
+ public Guid AircraftId { get; init; }
public string Name { get; init; }
public string Model { get; init; }
public int ManufacturingYear { get; init; }
diff --git a/src/Services/Flight/src/Flight/Airports/Features/AirportMappings.cs b/src/Services/Flight/src/Flight/Airports/Features/AirportMappings.cs
index 75bbd32..805f178 100644
--- a/src/Services/Flight/src/Flight/Airports/Features/AirportMappings.cs
+++ b/src/Services/Flight/src/Flight/Airports/Features/AirportMappings.cs
@@ -1,20 +1,20 @@
namespace Flight.Airports.Features;
-using BuildingBlocks.IdsGenerator;
-using Flight.Airports.Features.CreatingAirport.V1;
-using Flight.Airports.Models;
+using CreatingAirport.V1;
+using Models;
using Mapster;
+using MassTransit;
public class AirportMappings : IRegister
{
public void Register(TypeAdapterConfig config)
{
config.NewConfig()
- .Map(d => d.Id, s => SnowflakeIdGenerator.NewId())
+ .Map(d => d.Id, s => NewId.NextGuid())
.Map(d => d.AirportId, s => s.Id);
config.NewConfig()
- .Map(d => d.Id, s => SnowflakeIdGenerator.NewId())
+ .Map(d => d.Id, s => NewId.NextGuid())
.Map(d => d.AirportId, s => s.Id);
config.NewConfig()
diff --git a/src/Services/Flight/src/Flight/Airports/Features/CreatingAirport/V1/AirportCreatedDomainEvent.cs b/src/Services/Flight/src/Flight/Airports/Features/CreatingAirport/V1/AirportCreatedDomainEvent.cs
index 315a5b1..d0ea78d 100644
--- a/src/Services/Flight/src/Flight/Airports/Features/CreatingAirport/V1/AirportCreatedDomainEvent.cs
+++ b/src/Services/Flight/src/Flight/Airports/Features/CreatingAirport/V1/AirportCreatedDomainEvent.cs
@@ -1,5 +1,6 @@
namespace Flight.Airports.Features.CreatingAirport.V1;
+using System;
using BuildingBlocks.Core.Event;
-public record AirportCreatedDomainEvent(long Id, string Name, string Address, string Code, bool IsDeleted) : IDomainEvent;
+public record AirportCreatedDomainEvent(Guid Id, string Name, string Address, string Code, bool IsDeleted) : IDomainEvent;
diff --git a/src/Services/Flight/src/Flight/Airports/Features/CreatingAirport/V1/CreateAirport.cs b/src/Services/Flight/src/Flight/Airports/Features/CreatingAirport/V1/CreateAirport.cs
index 150ce60..0f7f802 100644
--- a/src/Services/Flight/src/Flight/Airports/Features/CreatingAirport/V1/CreateAirport.cs
+++ b/src/Services/Flight/src/Flight/Airports/Features/CreatingAirport/V1/CreateAirport.cs
@@ -1,25 +1,24 @@
namespace Flight.Airports.Features.CreatingAirport.V1;
+using System;
using System.Threading;
using System.Threading.Tasks;
using Ardalis.GuardClauses;
using BuildingBlocks.Core.CQRS;
using BuildingBlocks.Core.Event;
-using BuildingBlocks.IdsGenerator;
-using Dtos;
using Exceptions;
using Data;
using FluentValidation;
-using MapsterMapper;
+using MassTransit;
using MediatR;
using Microsoft.EntityFrameworkCore;
public record CreateAirport(string Name, string Address, string Code) : ICommand, IInternalCommand
{
- public long Id { get; init; } = SnowflakeIdGenerator.NewId();
+ public Guid Id { get; init; } = NewId.NextGuid();
}
-public record CreateAirportResult(long Id);
+public record CreateAirportResult(Guid Id);
internal class CreateAirportValidator : AbstractValidator
{
diff --git a/src/Services/Flight/src/Flight/Airports/Features/CreatingAirport/V1/CreateAirportEndpoint.cs b/src/Services/Flight/src/Flight/Airports/Features/CreatingAirport/V1/CreateAirportEndpoint.cs
index 8059fd0..63a54a8 100644
--- a/src/Services/Flight/src/Flight/Airports/Features/CreatingAirport/V1/CreateAirportEndpoint.cs
+++ b/src/Services/Flight/src/Flight/Airports/Features/CreatingAirport/V1/CreateAirportEndpoint.cs
@@ -1,5 +1,6 @@
namespace Flight.Airports.Features.CreatingAirport.V1;
+using System;
using System.Threading;
using System.Threading.Tasks;
using BuildingBlocks.Web;
@@ -11,7 +12,7 @@ using Microsoft.AspNetCore.Routing;
using Swashbuckle.AspNetCore.Annotations;
public record CreateAirportRequestDto(string Name, string Address, string Code);
-public record CreateAirportResponseDto(long Id);
+public record CreateAirportResponseDto(Guid Id);
public class CreateAirportEndpoint : IMinimalEndpoint
{
diff --git a/src/Services/Flight/src/Flight/Airports/Features/CreatingAirport/V1/CreateAirportMongo.cs b/src/Services/Flight/src/Flight/Airports/Features/CreatingAirport/V1/CreateAirportMongo.cs
index c46fc72..2f2e62b 100644
--- a/src/Services/Flight/src/Flight/Airports/Features/CreatingAirport/V1/CreateAirportMongo.cs
+++ b/src/Services/Flight/src/Flight/Airports/Features/CreatingAirport/V1/CreateAirportMongo.cs
@@ -1,5 +1,6 @@
namespace Flight.Airports.Features.CreatingAirport.V1;
+using System;
using System.Threading;
using System.Threading.Tasks;
using Ardalis.GuardClauses;
@@ -13,7 +14,7 @@ using MediatR;
using MongoDB.Driver;
using MongoDB.Driver.Linq;
-public record CreateAirportMongo(long Id, string Name, string Address, string Code, bool IsDeleted) : InternalCommand;
+public record CreateAirportMongo(Guid Id, string Name, string Address, string Code, bool IsDeleted) : InternalCommand;
internal class CreateAirportMongoHandler : ICommandHandler
{
diff --git a/src/Services/Flight/src/Flight/Airports/Models/Airport.cs b/src/Services/Flight/src/Flight/Airports/Models/Airport.cs
index 655f692..fbdd71d 100644
--- a/src/Services/Flight/src/Flight/Airports/Models/Airport.cs
+++ b/src/Services/Flight/src/Flight/Airports/Models/Airport.cs
@@ -1,17 +1,17 @@
using BuildingBlocks.Core.Model;
-using BuildingBlocks.IdsGenerator;
namespace Flight.Airports.Models;
+using System;
using Features.CreatingAirport.V1;
-public record Airport : Aggregate
+public record Airport : Aggregate
{
public string Name { get; private set; }
public string Address { get; private set; }
public string Code { get; private set; }
- public static Airport Create(long id, string name, string address, string code, bool isDeleted = false)
+ public static Airport Create(Guid id, string name, string address, string code, bool isDeleted = false)
{
var airport = new Airport
{
diff --git a/src/Services/Flight/src/Flight/Airports/Models/AirportReadModel.cs b/src/Services/Flight/src/Flight/Airports/Models/AirportReadModel.cs
index 5cc384d..d6d8f99 100644
--- a/src/Services/Flight/src/Flight/Airports/Models/AirportReadModel.cs
+++ b/src/Services/Flight/src/Flight/Airports/Models/AirportReadModel.cs
@@ -1,9 +1,11 @@
namespace Flight.Airports.Models;
+using System;
+
public class AirportReadModel
{
- public long Id { get; init; }
- public long AirportId { get; init; }
+ public Guid Id { get; init; }
+ public Guid AirportId { get; init; }
public string Name { get; init; }
public string Address { get; init; }
public string Code { get; init; }
diff --git a/src/Services/Flight/src/Flight/Data/Migrations/20230120222458_Init.Designer.cs b/src/Services/Flight/src/Flight/Data/Migrations/20230331144237_Init.Designer.cs
similarity index 92%
rename from src/Services/Flight/src/Flight/Data/Migrations/20230120222458_Init.Designer.cs
rename to src/Services/Flight/src/Flight/Data/Migrations/20230331144237_Init.Designer.cs
index b83b9b0..f60fc7d 100644
--- a/src/Services/Flight/src/Flight/Data/Migrations/20230120222458_Init.Designer.cs
+++ b/src/Services/Flight/src/Flight/Data/Migrations/20230331144237_Init.Designer.cs
@@ -12,7 +12,7 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
namespace Flight.Data.Migrations
{
[DbContext(typeof(FlightDbContext))]
- [Migration("20230120222458_Init")]
+ [Migration("20230331144237_Init")]
partial class Init
{
///
@@ -20,15 +20,15 @@ namespace Flight.Data.Migrations
{
#pragma warning disable 612, 618
modelBuilder
- .HasAnnotation("ProductVersion", "7.0.1")
+ .HasAnnotation("ProductVersion", "7.0.2")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("Flight.Aircrafts.Models.Aircraft", b =>
{
- b.Property("Id")
- .HasColumnType("bigint")
+ b.Property("Id")
+ .HasColumnType("uuid")
.HasColumnName("id");
b.Property("CreatedAt")
@@ -76,8 +76,8 @@ namespace Flight.Data.Migrations
modelBuilder.Entity("Flight.Airports.Models.Airport", b =>
{
- b.Property("Id")
- .HasColumnType("bigint")
+ b.Property("Id")
+ .HasColumnType("uuid")
.HasColumnName("id");
b.Property("Address")
@@ -125,16 +125,16 @@ namespace Flight.Data.Migrations
modelBuilder.Entity("Flight.Flights.Models.Flight", b =>
{
- b.Property("Id")
- .HasColumnType("bigint")
+ b.Property("Id")
+ .HasColumnType("uuid")
.HasColumnName("id");
- b.Property("AircraftId")
- .HasColumnType("bigint")
+ b.Property("AircraftId")
+ .HasColumnType("uuid")
.HasColumnName("aircraft_id");
- b.Property("ArriveAirportId")
- .HasColumnType("bigint")
+ b.Property("ArriveAirportId")
+ .HasColumnType("uuid")
.HasColumnName("arrive_airport_id");
b.Property("ArriveDate")
@@ -149,8 +149,8 @@ namespace Flight.Data.Migrations
.HasColumnType("bigint")
.HasColumnName("created_by");
- b.Property("DepartureAirportId")
- .HasColumnType("bigint")
+ b.Property("DepartureAirportId")
+ .HasColumnType("uuid")
.HasColumnName("departure_airport_id");
b.Property("DepartureDate")
@@ -211,8 +211,8 @@ namespace Flight.Data.Migrations
modelBuilder.Entity("Flight.Seats.Models.Seat", b =>
{
- b.Property("Id")
- .HasColumnType("bigint")
+ b.Property("Id")
+ .HasColumnType("uuid")
.HasColumnName("id");
b.Property("Class")
@@ -230,8 +230,8 @@ namespace Flight.Data.Migrations
.HasColumnType("bigint")
.HasColumnName("created_by");
- b.Property("FlightId")
- .HasColumnType("bigint")
+ b.Property("FlightId")
+ .HasColumnType("uuid")
.HasColumnName("flight_id");
b.Property("IsDeleted")
diff --git a/src/Services/Flight/src/Flight/Data/Migrations/20230120222458_Init.cs b/src/Services/Flight/src/Flight/Data/Migrations/20230331144237_Init.cs
similarity index 90%
rename from src/Services/Flight/src/Flight/Data/Migrations/20230120222458_Init.cs
rename to src/Services/Flight/src/Flight/Data/Migrations/20230331144237_Init.cs
index affce5c..7d7c5ec 100644
--- a/src/Services/Flight/src/Flight/Data/Migrations/20230120222458_Init.cs
+++ b/src/Services/Flight/src/Flight/Data/Migrations/20230331144237_Init.cs
@@ -15,7 +15,7 @@ namespace Flight.Data.Migrations
name: "aircraft",
columns: table => new
{
- id = table.Column(type: "bigint", nullable: false),
+ id = table.Column(type: "uuid", nullable: false),
name = table.Column(type: "text", nullable: true),
model = table.Column(type: "text", nullable: true),
manufacturingyear = table.Column(name: "manufacturing_year", type: "integer", nullable: false),
@@ -35,7 +35,7 @@ namespace Flight.Data.Migrations
name: "airport",
columns: table => new
{
- id = table.Column(type: "bigint", nullable: false),
+ id = table.Column(type: "uuid", nullable: false),
name = table.Column(type: "text", nullable: true),
address = table.Column(type: "text", nullable: true),
code = table.Column(type: "text", nullable: true),
@@ -55,13 +55,13 @@ namespace Flight.Data.Migrations
name: "flight",
columns: table => new
{
- id = table.Column(type: "bigint", nullable: false),
+ id = table.Column(type: "uuid", nullable: false),
flightnumber = table.Column(name: "flight_number", type: "text", nullable: true),
- aircraftid = table.Column(name: "aircraft_id", type: "bigint", nullable: false),
+ aircraftid = table.Column(name: "aircraft_id", type: "uuid", nullable: false),
departuredate = table.Column(name: "departure_date", type: "timestamp with time zone", nullable: false),
- departureairportid = table.Column(name: "departure_airport_id", type: "bigint", nullable: false),
+ departureairportid = table.Column(name: "departure_airport_id", type: "uuid", nullable: false),
arrivedate = table.Column(name: "arrive_date", type: "timestamp with time zone", nullable: false),
- arriveairportid = table.Column(name: "arrive_airport_id", type: "bigint", nullable: false),
+ arriveairportid = table.Column(name: "arrive_airport_id", type: "uuid", nullable: false),
durationminutes = table.Column(name: "duration_minutes", type: "numeric", nullable: false),
flightdate = table.Column(name: "flight_date", type: "timestamp with time zone", nullable: false),
status = table.Column(type: "text", nullable: false, defaultValue: "Unknown"),
@@ -94,11 +94,11 @@ namespace Flight.Data.Migrations
name: "seat",
columns: table => new
{
- id = table.Column(type: "bigint", nullable: false),
+ id = table.Column(type: "uuid", nullable: false),
seatnumber = table.Column(name: "seat_number", type: "text", nullable: true),
type = table.Column(type: "text", nullable: false, defaultValue: "Unknown"),
@class = table.Column(name: "class", type: "text", nullable: false, defaultValue: "Unknown"),
- flightid = table.Column(name: "flight_id", type: "bigint", nullable: false),
+ flightid = table.Column(name: "flight_id", type: "uuid", nullable: false),
createdat = table.Column(name: "created_at", type: "timestamp with time zone", nullable: true),
createdby = table.Column(name: "created_by", type: "bigint", nullable: true),
lastmodified = table.Column(name: "last_modified", type: "timestamp with time zone", nullable: true),
diff --git a/src/Services/Flight/src/Flight/Data/Migrations/FlightDbContextModelSnapshot.cs b/src/Services/Flight/src/Flight/Data/Migrations/FlightDbContextModelSnapshot.cs
index 8a46c93..5df1ffd 100644
--- a/src/Services/Flight/src/Flight/Data/Migrations/FlightDbContextModelSnapshot.cs
+++ b/src/Services/Flight/src/Flight/Data/Migrations/FlightDbContextModelSnapshot.cs
@@ -17,15 +17,15 @@ namespace Flight.Data.Migrations
{
#pragma warning disable 612, 618
modelBuilder
- .HasAnnotation("ProductVersion", "7.0.1")
+ .HasAnnotation("ProductVersion", "7.0.2")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("Flight.Aircrafts.Models.Aircraft", b =>
{
- b.Property("Id")
- .HasColumnType("bigint")
+ b.Property("Id")
+ .HasColumnType("uuid")
.HasColumnName("id");
b.Property("CreatedAt")
@@ -73,8 +73,8 @@ namespace Flight.Data.Migrations
modelBuilder.Entity("Flight.Airports.Models.Airport", b =>
{
- b.Property("Id")
- .HasColumnType("bigint")
+ b.Property("Id")
+ .HasColumnType("uuid")
.HasColumnName("id");
b.Property("Address")
@@ -122,16 +122,16 @@ namespace Flight.Data.Migrations
modelBuilder.Entity("Flight.Flights.Models.Flight", b =>
{
- b.Property("Id")
- .HasColumnType("bigint")
+ b.Property("Id")
+ .HasColumnType("uuid")
.HasColumnName("id");
- b.Property("AircraftId")
- .HasColumnType("bigint")
+ b.Property("AircraftId")
+ .HasColumnType("uuid")
.HasColumnName("aircraft_id");
- b.Property("ArriveAirportId")
- .HasColumnType("bigint")
+ b.Property("ArriveAirportId")
+ .HasColumnType("uuid")
.HasColumnName("arrive_airport_id");
b.Property("ArriveDate")
@@ -146,8 +146,8 @@ namespace Flight.Data.Migrations
.HasColumnType("bigint")
.HasColumnName("created_by");
- b.Property("DepartureAirportId")
- .HasColumnType("bigint")
+ b.Property("DepartureAirportId")
+ .HasColumnType("uuid")
.HasColumnName("departure_airport_id");
b.Property("DepartureDate")
@@ -208,8 +208,8 @@ namespace Flight.Data.Migrations
modelBuilder.Entity("Flight.Seats.Models.Seat", b =>
{
- b.Property("Id")
- .HasColumnType("bigint")
+ b.Property("Id")
+ .HasColumnType("uuid")
.HasColumnName("id");
b.Property("Class")
@@ -227,8 +227,8 @@ namespace Flight.Data.Migrations
.HasColumnType("bigint")
.HasColumnName("created_by");
- b.Property("FlightId")
- .HasColumnType("bigint")
+ b.Property("FlightId")
+ .HasColumnType("uuid")
.HasColumnName("flight_id");
b.Property("IsDeleted")
diff --git a/src/Services/Flight/src/Flight/Data/Seed/FlightDataSeeder.cs b/src/Services/Flight/src/Flight/Data/Seed/FlightDataSeeder.cs
index fb66552..977199d 100644
--- a/src/Services/Flight/src/Flight/Data/Seed/FlightDataSeeder.cs
+++ b/src/Services/Flight/src/Flight/Data/Seed/FlightDataSeeder.cs
@@ -1,4 +1,3 @@
-using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using BuildingBlocks.EFCore;
@@ -41,17 +40,13 @@ public class FlightDataSeeder : IDataSeeder
{
if (!await _flightDbContext.Airports.AnyAsync())
{
- var airports = new List
- {
- Airport.Create(1, "Lisbon International Airport", "LIS", "12988"),
- Airport.Create(2, "Sao Paulo International Airport", "BRZ", "11200")
- };
-
- await _flightDbContext.Airports.AddRangeAsync(airports);
+ await _flightDbContext.Airports.AddRangeAsync(InitialData.Airports);
await _flightDbContext.SaveChangesAsync();
if (!await _flightReadDbContext.Airport.AsQueryable().AnyAsync())
- await _flightReadDbContext.Airport.InsertManyAsync(_mapper.Map>(airports));
+ {
+ await _flightReadDbContext.Airport.InsertManyAsync(_mapper.Map>(InitialData.Airports));
+ }
}
}
@@ -59,18 +54,13 @@ public class FlightDataSeeder : IDataSeeder
{
if (!await _flightDbContext.Aircraft.AnyAsync())
{
- var aircrafts = new List
- {
- Aircraft.Create(1, "Boeing 737", "B737", 2005),
- Aircraft.Create(2, "Airbus 300", "A300", 2000),
- Aircraft.Create(3, "Airbus 320", "A320", 2003)
- };
-
- await _flightDbContext.Aircraft.AddRangeAsync(aircrafts);
+ await _flightDbContext.Aircraft.AddRangeAsync(InitialData.Aircrafts);
await _flightDbContext.SaveChangesAsync();
if (!await _flightReadDbContext.Aircraft.AsQueryable().AnyAsync())
- await _flightReadDbContext.Aircraft.InsertManyAsync(_mapper.Map>(aircrafts));
+ {
+ await _flightReadDbContext.Aircraft.InsertManyAsync(_mapper.Map>(InitialData.Aircrafts));
+ }
}
}
@@ -79,21 +69,13 @@ public class FlightDataSeeder : IDataSeeder
{
if (!await _flightDbContext.Seats.AnyAsync())
{
- var seats = new List
- {
- Seat.Create(1, "12A", Seats.Enums.SeatType.Window, Seats.Enums.SeatClass.Economy, 1),
- Seat.Create(2, "12B", Seats.Enums.SeatType.Window, Seats.Enums.SeatClass.Economy, 1),
- Seat.Create(3, "12C", Seats.Enums.SeatType.Middle, Seats.Enums.SeatClass.Economy, 1),
- Seat.Create(4, "12D", Seats.Enums.SeatType.Middle, Seats.Enums.SeatClass.Economy, 1),
- Seat.Create(5, "12E", Seats.Enums.SeatType.Aisle, Seats.Enums.SeatClass.Economy, 1),
- Seat.Create(6, "12F", Seats.Enums.SeatType.Aisle, Seats.Enums.SeatClass.Economy, 1)
- };
-
- await _flightDbContext.Seats.AddRangeAsync(seats);
+ await _flightDbContext.Seats.AddRangeAsync(InitialData.Seats);
await _flightDbContext.SaveChangesAsync();
if (!await _flightReadDbContext.Seat.AsQueryable().AnyAsync())
- await _flightReadDbContext.Seat.InsertManyAsync(_mapper.Map>(seats));
+ {
+ await _flightReadDbContext.Seat.InsertManyAsync(_mapper.Map>(InitialData.Seats));
+ }
}
}
@@ -101,19 +83,13 @@ public class FlightDataSeeder : IDataSeeder
{
if (!await _flightDbContext.Flights.AnyAsync())
{
- var flights = new List
- {
- Flights.Models.Flight.Create(1, "BD467", 1, 1, new DateTime(2022, 1, 31, 12, 0, 0),
- new DateTime(2022, 1, 31, 14, 0, 0),
- 2, 120m,
- new DateTime(2022, 1, 31), Flights.Enums.FlightStatus.Completed,
- 8000)
- };
- await _flightDbContext.Flights.AddRangeAsync(flights);
+ await _flightDbContext.Flights.AddRangeAsync(InitialData.Flights);
await _flightDbContext.SaveChangesAsync();
if (!await _flightReadDbContext.Flight.AsQueryable().AnyAsync())
- await _flightReadDbContext.Flight.InsertManyAsync(_mapper.Map>(flights));
+ {
+ await _flightReadDbContext.Flight.InsertManyAsync(_mapper.Map>(InitialData.Flights));
+ }
}
}
}
diff --git a/src/Services/Flight/src/Flight/Data/Seed/InitialData.cs b/src/Services/Flight/src/Flight/Data/Seed/InitialData.cs
new file mode 100644
index 0000000..2953dd7
--- /dev/null
+++ b/src/Services/Flight/src/Flight/Data/Seed/InitialData.cs
@@ -0,0 +1,55 @@
+namespace Flight.Data.Seed;
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using Aircrafts.Models;
+using Airports.Models;
+using Flights.Models;
+using MassTransit;
+using Seats.Models;
+
+public static class InitialData
+{
+ public static List Airports { get;}
+ public static List Aircrafts { get;}
+ public static List Seats { get;}
+ public static List Flights { get; }
+
+
+ static InitialData()
+ {
+ Airports = new List
+ {
+ Airport.Create(new Guid("3c5c0000-97c6-fc34-a0cb-08db322230c8"), "Lisbon International Airport", "LIS", "12988"),
+ Airport.Create(new Guid("3c5c0000-97c6-fc34-fc3c-08db322230c8"), "Sao Paulo International Airport", "BRZ", "11200")
+ };
+
+ Aircrafts = new List
+ {
+ Aircraft.Create(new Guid("3c5c0000-97c6-fc34-fcd3-08db322230c8"), "Boeing 737", "B737", 2005),
+ Aircraft.Create(new Guid("3c5c0000-97c6-fc34-2e04-08db322230c9"), "Airbus 300", "A300", 2000),
+ Aircraft.Create(new Guid("3c5c0000-97c6-fc34-2e11-08db322230c9"), "Airbus 320", "A320", 2003)
+ };
+
+
+ Flights = new List
+ {
+ Flight.Create(new Guid("3c5c0000-97c6-fc34-2eb9-08db322230c9"), "BD467", Aircrafts.First().Id, Airports.First().Id, new DateTime(2022, 1, 31, 12, 0, 0),
+ new DateTime(2022, 1, 31, 14, 0, 0),
+ Airports.Last().Id, 120m,
+ new DateTime(2022, 1, 31), global::Flight.Flights.Enums.FlightStatus.Completed,
+ 8000)
+ };
+
+ Seats = new List
+ {
+ Seat.Create(NewId.NextGuid(), "12A", global::Flight.Seats.Enums.SeatType.Window, global::Flight.Seats.Enums.SeatClass.Economy, Flights.First().Id),
+ Seat.Create(NewId.NextGuid(), "12B", global::Flight.Seats.Enums.SeatType.Window, global::Flight.Seats.Enums.SeatClass.Economy, Flights.First().Id),
+ Seat.Create(NewId.NextGuid(), "12C", global::Flight.Seats.Enums.SeatType.Middle, global::Flight.Seats.Enums.SeatClass.Economy, Flights.First().Id),
+ Seat.Create(NewId.NextGuid(), "12D", global::Flight.Seats.Enums.SeatType.Middle, global::Flight.Seats.Enums.SeatClass.Economy, Flights.First().Id),
+ Seat.Create(NewId.NextGuid(), "12E", global::Flight.Seats.Enums.SeatType.Aisle, global::Flight.Seats.Enums.SeatClass.Economy, Flights.First().Id),
+ Seat.Create(NewId.NextGuid(), "12F", global::Flight.Seats.Enums.SeatType.Aisle, global::Flight.Seats.Enums.SeatClass.Economy, Flights.First().Id)
+ };
+ }
+}
diff --git a/src/Services/Flight/src/Flight/Extensions/Infrastructure/InfrastructureExtensions.cs b/src/Services/Flight/src/Flight/Extensions/Infrastructure/InfrastructureExtensions.cs
index 82558e7..04cc878 100644
--- a/src/Services/Flight/src/Flight/Extensions/Infrastructure/InfrastructureExtensions.cs
+++ b/src/Services/Flight/src/Flight/Extensions/Infrastructure/InfrastructureExtensions.cs
@@ -4,7 +4,6 @@ using BuildingBlocks.Core;
using BuildingBlocks.EFCore;
using BuildingBlocks.Exception;
using BuildingBlocks.HealthCheck;
-using BuildingBlocks.IdsGenerator;
using BuildingBlocks.Jwt;
using BuildingBlocks.Logging;
using BuildingBlocks.Mapster;
@@ -38,9 +37,6 @@ public static class InfrastructureExtensions
var configuration = builder.Configuration;
var env = builder.Environment;
- // https://github.com/tonerdo/dotnet-env
- DotNetEnv.Env.TraversePath().Load();
-
builder.Services.AddScoped();
builder.Services.AddScoped();
builder.Services.AddScoped();
diff --git a/src/Services/Flight/src/Flight/Flights/Dtos/FlightDto.cs b/src/Services/Flight/src/Flight/Flights/Dtos/FlightDto.cs
index fbfe7a1..9610506 100644
--- a/src/Services/Flight/src/Flight/Flights/Dtos/FlightDto.cs
+++ b/src/Services/Flight/src/Flight/Flights/Dtos/FlightDto.cs
@@ -2,6 +2,6 @@ using System;
namespace Flight.Flights.Dtos;
-public record FlightDto(long Id, string FlightNumber, long AircraftId, long DepartureAirportId,
- DateTime DepartureDate, DateTime ArriveDate, long ArriveAirportId, decimal DurationMinutes, DateTime FlightDate,
+public record FlightDto(Guid Id, string FlightNumber, Guid AircraftId, Guid DepartureAirportId,
+ DateTime DepartureDate, DateTime ArriveDate, Guid ArriveAirportId, decimal DurationMinutes, DateTime FlightDate,
Enums.FlightStatus Status, decimal Price);
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 e41b17b..8572ce8 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
@@ -6,23 +6,21 @@ using System.Threading.Tasks;
using Ardalis.GuardClauses;
using BuildingBlocks.Core.CQRS;
using BuildingBlocks.Core.Event;
-using BuildingBlocks.IdsGenerator;
using Data;
-using Dtos;
using Exceptions;
using FluentValidation;
-using MapsterMapper;
+using MassTransit;
using Microsoft.EntityFrameworkCore;
-public record CreateFlight(string FlightNumber, long AircraftId, long DepartureAirportId,
- DateTime DepartureDate, DateTime ArriveDate, long ArriveAirportId,
+public record CreateFlight(string FlightNumber, Guid AircraftId, Guid DepartureAirportId,
+ DateTime DepartureDate, DateTime ArriveDate, Guid ArriveAirportId,
decimal DurationMinutes, DateTime FlightDate, Enums.FlightStatus Status,
decimal Price) : ICommand, IInternalCommand
{
- public long Id { get; init; } = SnowflakeIdGenerator.NewId();
+ public Guid Id { get; init; } = NewId.NextGuid();
}
-public record CreateFlightResult(long Id);
+public record CreateFlightResult(Guid Id);
internal class CreateFlightValidator : AbstractValidator
{
diff --git a/src/Services/Flight/src/Flight/Flights/Features/CreatingFlight/V1/CreateFlightEndpoint.cs b/src/Services/Flight/src/Flight/Flights/Features/CreatingFlight/V1/CreateFlightEndpoint.cs
index d71c0eb..8bb1d50 100644
--- a/src/Services/Flight/src/Flight/Flights/Features/CreatingFlight/V1/CreateFlightEndpoint.cs
+++ b/src/Services/Flight/src/Flight/Flights/Features/CreatingFlight/V1/CreateFlightEndpoint.cs
@@ -11,11 +11,11 @@ using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Routing;
using Swashbuckle.AspNetCore.Annotations;
-public record CreateFlightRequestDto(string FlightNumber, long AircraftId, long DepartureAirportId,
- DateTime DepartureDate, DateTime ArriveDate, long ArriveAirportId,
+public record CreateFlightRequestDto(string FlightNumber, Guid AircraftId, Guid DepartureAirportId,
+ DateTime DepartureDate, DateTime ArriveDate, Guid ArriveAirportId,
decimal DurationMinutes, DateTime FlightDate, Enums.FlightStatus Status, decimal Price);
-public record CreateFlightResponseDto(long Id);
+public record CreateFlightResponseDto(Guid Id);
public class CreateFlightEndpoint : IMinimalEndpoint
{
diff --git a/src/Services/Flight/src/Flight/Flights/Features/CreatingFlight/V1/CreateFlightMongo.cs b/src/Services/Flight/src/Flight/Flights/Features/CreatingFlight/V1/CreateFlightMongo.cs
index feef219..7327044 100644
--- a/src/Services/Flight/src/Flight/Flights/Features/CreatingFlight/V1/CreateFlightMongo.cs
+++ b/src/Services/Flight/src/Flight/Flights/Features/CreatingFlight/V1/CreateFlightMongo.cs
@@ -6,16 +6,16 @@ using System.Threading.Tasks;
using Ardalis.GuardClauses;
using BuildingBlocks.Core.CQRS;
using BuildingBlocks.Core.Event;
-using Flight.Data;
-using Flight.Flights.Exceptions;
+using Data;
+using Exceptions;
using MapsterMapper;
using MediatR;
using Models;
using MongoDB.Driver;
using MongoDB.Driver.Linq;
-public record CreateFlightMongo(long Id, string FlightNumber, long AircraftId, DateTime DepartureDate,
- long DepartureAirportId, DateTime ArriveDate, long ArriveAirportId, decimal DurationMinutes, DateTime FlightDate,
+public record CreateFlightMongo(Guid Id, string FlightNumber, Guid AircraftId, DateTime DepartureDate,
+ Guid DepartureAirportId, DateTime ArriveDate, Guid ArriveAirportId, decimal DurationMinutes, DateTime FlightDate,
Enums.FlightStatus Status, decimal Price, bool IsDeleted) : InternalCommand;
internal class CreateFlightMongoHandler : ICommandHandler
diff --git a/src/Services/Flight/src/Flight/Flights/Features/CreatingFlight/V1/FlightCreatedDomainEvent.cs b/src/Services/Flight/src/Flight/Flights/Features/CreatingFlight/V1/FlightCreatedDomainEvent.cs
index aaa3123..0d5b31d 100644
--- a/src/Services/Flight/src/Flight/Flights/Features/CreatingFlight/V1/FlightCreatedDomainEvent.cs
+++ b/src/Services/Flight/src/Flight/Flights/Features/CreatingFlight/V1/FlightCreatedDomainEvent.cs
@@ -3,6 +3,6 @@ namespace Flight.Flights.Features.CreatingFlight.V1;
using System;
using BuildingBlocks.Core.Event;
-public record FlightCreatedDomainEvent(long Id, string FlightNumber, long AircraftId, DateTime DepartureDate,
- long DepartureAirportId, DateTime ArriveDate, long ArriveAirportId, decimal DurationMinutes,
+public record FlightCreatedDomainEvent(Guid Id, string FlightNumber, Guid AircraftId, DateTime DepartureDate,
+ Guid DepartureAirportId, DateTime ArriveDate, Guid ArriveAirportId, decimal DurationMinutes,
DateTime FlightDate, Enums.FlightStatus Status, decimal Price, bool IsDeleted) : IDomainEvent;
diff --git a/src/Services/Flight/src/Flight/Flights/Features/DeletingFlight/V1/DeleteFlight.cs b/src/Services/Flight/src/Flight/Flights/Features/DeletingFlight/V1/DeleteFlight.cs
index a72731c..55b5f2c 100644
--- a/src/Services/Flight/src/Flight/Flights/Features/DeletingFlight/V1/DeleteFlight.cs
+++ b/src/Services/Flight/src/Flight/Flights/Features/DeletingFlight/V1/DeleteFlight.cs
@@ -1,20 +1,19 @@
namespace Flight.Flights.Features.DeletingFlight.V1;
+using System;
using System.Threading;
using System.Threading.Tasks;
using Ardalis.GuardClauses;
using BuildingBlocks.Core.CQRS;
using BuildingBlocks.Core.Event;
using Data;
-using Dtos;
using Exceptions;
using FluentValidation;
-using MapsterMapper;
using Microsoft.EntityFrameworkCore;
-public record DeleteFlight(long Id) : ICommand, IInternalCommand;
+public record DeleteFlight(Guid Id) : ICommand, IInternalCommand;
-public record DeleteFlightResult(long Id);
+public record DeleteFlightResult(Guid Id);
internal class DeleteFlightValidator : AbstractValidator
{
diff --git a/src/Services/Flight/src/Flight/Flights/Features/DeletingFlight/V1/DeleteFlightEndpoint.cs b/src/Services/Flight/src/Flight/Flights/Features/DeletingFlight/V1/DeleteFlightEndpoint.cs
index 6a1b83b..c0a3d32 100644
--- a/src/Services/Flight/src/Flight/Flights/Features/DeletingFlight/V1/DeleteFlightEndpoint.cs
+++ b/src/Services/Flight/src/Flight/Flights/Features/DeletingFlight/V1/DeleteFlightEndpoint.cs
@@ -1,5 +1,6 @@
namespace Flight.Flights.Features.DeletingFlight.V1;
+using System;
using System.Threading;
using System.Threading.Tasks;
using BuildingBlocks.Web;
@@ -25,7 +26,7 @@ public class DeleteFlightEndpoint : IMinimalEndpoint
return builder;
}
- private async Task DeleteFlight(long id, IMediator mediator, CancellationToken cancellationToken)
+ private async Task DeleteFlight(Guid id, IMediator mediator, CancellationToken cancellationToken)
{
var result = await mediator.Send(new DeleteFlight(id), cancellationToken);
diff --git a/src/Services/Flight/src/Flight/Flights/Features/DeletingFlight/V1/DeleteFlightMongo.cs b/src/Services/Flight/src/Flight/Flights/Features/DeletingFlight/V1/DeleteFlightMongo.cs
index 2879e5c..8139855 100644
--- a/src/Services/Flight/src/Flight/Flights/Features/DeletingFlight/V1/DeleteFlightMongo.cs
+++ b/src/Services/Flight/src/Flight/Flights/Features/DeletingFlight/V1/DeleteFlightMongo.cs
@@ -14,8 +14,8 @@ using Models;
using MongoDB.Driver;
using MongoDB.Driver.Linq;
-public record DeleteFlightMongo(long Id, string FlightNumber, long AircraftId, DateTime DepartureDate,
- long DepartureAirportId, DateTime ArriveDate, long ArriveAirportId, decimal DurationMinutes, DateTime FlightDate,
+public record DeleteFlightMongo(Guid Id, string FlightNumber, Guid AircraftId, DateTime DepartureDate,
+ Guid DepartureAirportId, DateTime ArriveDate, Guid ArriveAirportId, decimal DurationMinutes, DateTime FlightDate,
Enums.FlightStatus Status, decimal Price, bool IsDeleted) : InternalCommand;
internal class DeleteFlightMongoCommandHandler : ICommandHandler
diff --git a/src/Services/Flight/src/Flight/Flights/Features/DeletingFlight/V1/FlightDeletedDomainEvent.cs b/src/Services/Flight/src/Flight/Flights/Features/DeletingFlight/V1/FlightDeletedDomainEvent.cs
index a6813b7..06ed2dc 100644
--- a/src/Services/Flight/src/Flight/Flights/Features/DeletingFlight/V1/FlightDeletedDomainEvent.cs
+++ b/src/Services/Flight/src/Flight/Flights/Features/DeletingFlight/V1/FlightDeletedDomainEvent.cs
@@ -3,6 +3,6 @@
using System;
using BuildingBlocks.Core.Event;
-public record FlightDeletedDomainEvent(long Id, string FlightNumber, long AircraftId, DateTime DepartureDate,
- long DepartureAirportId, DateTime ArriveDate, long ArriveAirportId, decimal DurationMinutes,
+public record FlightDeletedDomainEvent(Guid Id, string FlightNumber, Guid AircraftId, DateTime DepartureDate,
+ Guid DepartureAirportId, DateTime ArriveDate, Guid ArriveAirportId, decimal DurationMinutes,
DateTime FlightDate, Enums.FlightStatus Status, decimal Price, bool IsDeleted) : IDomainEvent;
diff --git a/src/Services/Flight/src/Flight/Flights/Features/FlightMappings.cs b/src/Services/Flight/src/Flight/Flights/Features/FlightMappings.cs
index e3c7541..5b529f6 100644
--- a/src/Services/Flight/src/Flight/Flights/Features/FlightMappings.cs
+++ b/src/Services/Flight/src/Flight/Flights/Features/FlightMappings.cs
@@ -1,4 +1,3 @@
-using BuildingBlocks.IdsGenerator;
using Mapster;
namespace Flight.Flights.Features;
@@ -6,6 +5,7 @@ namespace Flight.Flights.Features;
using CreatingFlight.V1;
using DeletingFlight.V1;
using GettingAvailableFlights.V1;
+using MassTransit;
using Models;
using UpdatingFlight.V1;
using FlightDto = Dtos.FlightDto;
@@ -19,11 +19,11 @@ public class FlightMappings : IRegister
x.ArriveDate, x.ArriveAirportId, x.DurationMinutes, x.FlightDate, x.Status, x.Price));
config.NewConfig()
- .Map(d => d.Id, s => SnowflakeIdGenerator.NewId())
+ .Map(d => d.Id, s => NewId.NextGuid())
.Map(d => d.FlightId, s => s.Id);
config.NewConfig()
- .Map(d => d.Id, s => SnowflakeIdGenerator.NewId())
+ .Map(d => d.Id, s => NewId.NextGuid())
.Map(d => d.FlightId, s => s.Id);
config.NewConfig()
diff --git a/src/Services/Flight/src/Flight/Flights/Features/GettingFlightById/V1/GetFlightById.cs b/src/Services/Flight/src/Flight/Flights/Features/GettingFlightById/V1/GetFlightById.cs
index 8213f09..e7d7a68 100644
--- a/src/Services/Flight/src/Flight/Flights/Features/GettingFlightById/V1/GetFlightById.cs
+++ b/src/Services/Flight/src/Flight/Flights/Features/GettingFlightById/V1/GetFlightById.cs
@@ -1,5 +1,6 @@
namespace Flight.Flights.Features.GettingFlightById.V1;
+using System;
using System.Threading;
using System.Threading.Tasks;
using Ardalis.GuardClauses;
@@ -12,7 +13,7 @@ using MapsterMapper;
using MongoDB.Driver;
using MongoDB.Driver.Linq;
-public record GetFlightById(long Id) : IQuery;
+public record GetFlightById(Guid Id) : IQuery;
public record GetFlightByIdResult(FlightDto FlightDto);
diff --git a/src/Services/Flight/src/Flight/Flights/Features/GettingFlightById/V1/GetFlightByIdEndpoint.cs b/src/Services/Flight/src/Flight/Flights/Features/GettingFlightById/V1/GetFlightByIdEndpoint.cs
index 0ad4c07..3e37eb2 100644
--- a/src/Services/Flight/src/Flight/Flights/Features/GettingFlightById/V1/GetFlightByIdEndpoint.cs
+++ b/src/Services/Flight/src/Flight/Flights/Features/GettingFlightById/V1/GetFlightByIdEndpoint.cs
@@ -1,5 +1,6 @@
namespace Flight.Flights.Features.GettingFlightById.V1;
+using System;
using System.Threading;
using System.Threading.Tasks;
using BuildingBlocks.Web;
@@ -28,7 +29,7 @@ public class GetFlightByIdEndpoint : IMinimalEndpoint
return builder;
}
- private async Task GetById(long id, IMediator mediator, CancellationToken cancellationToken)
+ private async Task GetById(Guid id, IMediator mediator, CancellationToken cancellationToken)
{
var result = await mediator.Send(new GetFlightById(id), cancellationToken);
diff --git a/src/Services/Flight/src/Flight/Flights/Features/UpdatingFlight/V1/FlightUpdatedDomainEvent.cs b/src/Services/Flight/src/Flight/Flights/Features/UpdatingFlight/V1/FlightUpdatedDomainEvent.cs
index 0c08696..6739a70 100644
--- a/src/Services/Flight/src/Flight/Flights/Features/UpdatingFlight/V1/FlightUpdatedDomainEvent.cs
+++ b/src/Services/Flight/src/Flight/Flights/Features/UpdatingFlight/V1/FlightUpdatedDomainEvent.cs
@@ -3,6 +3,6 @@ namespace Flight.Flights.Features.UpdatingFlight.V1;
using System;
using BuildingBlocks.Core.Event;
-public record FlightUpdatedDomainEvent(long Id, string FlightNumber, long AircraftId, DateTime DepartureDate,
- long DepartureAirportId, DateTime ArriveDate, long ArriveAirportId, decimal DurationMinutes,
+public record FlightUpdatedDomainEvent(Guid Id, string FlightNumber, Guid AircraftId, DateTime DepartureDate,
+ Guid DepartureAirportId, DateTime ArriveDate, Guid ArriveAirportId, decimal DurationMinutes,
DateTime FlightDate, Enums.FlightStatus Status, decimal Price, bool IsDeleted) : IDomainEvent;
diff --git a/src/Services/Flight/src/Flight/Flights/Features/UpdatingFlight/V1/UpdateFlight.cs b/src/Services/Flight/src/Flight/Flights/Features/UpdatingFlight/V1/UpdateFlight.cs
index dc83542..2dde4fd 100644
--- a/src/Services/Flight/src/Flight/Flights/Features/UpdatingFlight/V1/UpdateFlight.cs
+++ b/src/Services/Flight/src/Flight/Flights/Features/UpdatingFlight/V1/UpdateFlight.cs
@@ -7,23 +7,21 @@ using Ardalis.GuardClauses;
using BuildingBlocks.Caching;
using BuildingBlocks.Core.CQRS;
using BuildingBlocks.Core.Event;
-using Flight.Data;
-using Flight.Flights.Dtos;
-using Flight.Flights.Exceptions;
+using Data;
+using Exceptions;
using Flight.Flights.Features.CreatingFlight.V1;
using FluentValidation;
-using MapsterMapper;
using Microsoft.EntityFrameworkCore;
-public record UpdateFlight(long Id, string FlightNumber, long AircraftId, long DepartureAirportId,
- DateTime DepartureDate, DateTime ArriveDate, long ArriveAirportId, decimal DurationMinutes, DateTime FlightDate,
+public record UpdateFlight(Guid Id, string FlightNumber, Guid AircraftId, Guid DepartureAirportId,
+ DateTime DepartureDate, DateTime ArriveDate, Guid ArriveAirportId, decimal DurationMinutes, DateTime FlightDate,
Enums.FlightStatus Status, bool IsDeleted, decimal Price) : ICommand, IInternalCommand,
IInvalidateCacheRequest
{
public string CacheKey => "GetAvailableFlights";
}
-public record UpdateFlightResult(long Id);
+public record UpdateFlightResult(Guid Id);
internal class UpdateFlightValidator : AbstractValidator
{
diff --git a/src/Services/Flight/src/Flight/Flights/Features/UpdatingFlight/V1/UpdateFlightEndpoint.cs b/src/Services/Flight/src/Flight/Flights/Features/UpdatingFlight/V1/UpdateFlightEndpoint.cs
index 30af956..e4cdb50 100644
--- a/src/Services/Flight/src/Flight/Flights/Features/UpdatingFlight/V1/UpdateFlightEndpoint.cs
+++ b/src/Services/Flight/src/Flight/Flights/Features/UpdatingFlight/V1/UpdateFlightEndpoint.cs
@@ -11,8 +11,8 @@ using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Routing;
using Swashbuckle.AspNetCore.Annotations;
-public record UpdateFlightRequestDto(long Id, string FlightNumber, long AircraftId, long DepartureAirportId, DateTime DepartureDate, DateTime ArriveDate,
- long ArriveAirportId, decimal DurationMinutes, DateTime FlightDate, Enums.FlightStatus Status, decimal Price, bool IsDeleted);
+public record UpdateFlightRequestDto(Guid Id, string FlightNumber, Guid AircraftId, Guid DepartureAirportId, DateTime DepartureDate, DateTime ArriveDate,
+ Guid ArriveAirportId, decimal DurationMinutes, DateTime FlightDate, Enums.FlightStatus Status, decimal Price, bool IsDeleted);
public class UpdateFlightEndpoint : IMinimalEndpoint
{
diff --git a/src/Services/Flight/src/Flight/Flights/Features/UpdatingFlight/V1/UpdateFlightMongo.cs b/src/Services/Flight/src/Flight/Flights/Features/UpdatingFlight/V1/UpdateFlightMongo.cs
index d3eb683..8424567 100644
--- a/src/Services/Flight/src/Flight/Flights/Features/UpdatingFlight/V1/UpdateFlightMongo.cs
+++ b/src/Services/Flight/src/Flight/Flights/Features/UpdatingFlight/V1/UpdateFlightMongo.cs
@@ -14,8 +14,8 @@ using Models;
using MongoDB.Driver;
using MongoDB.Driver.Linq;
-public record UpdateFlightMongo(long Id, string FlightNumber, long AircraftId, DateTime DepartureDate,
- long DepartureAirportId, DateTime ArriveDate, long ArriveAirportId, decimal DurationMinutes, DateTime FlightDate,
+public record UpdateFlightMongo(Guid Id, string FlightNumber, Guid AircraftId, DateTime DepartureDate,
+ Guid DepartureAirportId, DateTime ArriveDate, Guid ArriveAirportId, decimal DurationMinutes, DateTime FlightDate,
Enums.FlightStatus Status, decimal Price, bool IsDeleted) : InternalCommand;
diff --git a/src/Services/Flight/src/Flight/Flights/Models/Flight.cs b/src/Services/Flight/src/Flight/Flights/Models/Flight.cs
index d0b4fd5..86ab7a7 100644
--- a/src/Services/Flight/src/Flight/Flights/Models/Flight.cs
+++ b/src/Services/Flight/src/Flight/Flights/Models/Flight.cs
@@ -7,22 +7,22 @@ using Features.CreatingFlight.V1;
using Features.DeletingFlight.V1;
using Features.UpdatingFlight.V1;
-public record Flight : Aggregate
+public record Flight : Aggregate
{
public string FlightNumber { get; private set; }
- public long AircraftId { get; private set; }
+ public Guid AircraftId { get; private set; }
public DateTime DepartureDate { get; private set; }
- public long DepartureAirportId { get; private set; }
+ public Guid DepartureAirportId { get; private set; }
public DateTime ArriveDate { get; private set; }
- public long ArriveAirportId { get; private set; }
+ public Guid ArriveAirportId { get; private set; }
public decimal DurationMinutes { get; private set; }
public DateTime FlightDate { get; private set; }
public Enums.FlightStatus Status { get; private set; }
public decimal Price { get; private set; }
- public static Flight Create(long id, string flightNumber, long aircraftId,
- long departureAirportId, DateTime departureDate, DateTime arriveDate,
- long arriveAirportId, decimal durationMinutes, DateTime flightDate, Enums.FlightStatus status,
+ public static Flight Create(Guid id, string flightNumber, Guid aircraftId,
+ Guid departureAirportId, DateTime departureDate, DateTime arriveDate,
+ Guid arriveAirportId, decimal durationMinutes, DateTime flightDate, Enums.FlightStatus status,
decimal price, bool isDeleted = false)
{
var flight = new Flight
@@ -52,9 +52,9 @@ public record Flight : Aggregate
}
- public void Update(long id, string flightNumber, long aircraftId,
- long departureAirportId, DateTime departureDate, DateTime arriveDate,
- long arriveAirportId, decimal durationMinutes, DateTime flightDate, Enums.FlightStatus status,
+ public void Update(Guid id, string flightNumber, Guid aircraftId,
+ Guid departureAirportId, DateTime departureDate, DateTime arriveDate,
+ Guid arriveAirportId, decimal durationMinutes, DateTime flightDate, Enums.FlightStatus status,
decimal price, bool isDeleted = false)
{
FlightNumber = flightNumber;
@@ -75,9 +75,9 @@ public record Flight : Aggregate
AddDomainEvent(@event);
}
- public void Delete(long id, string flightNumber, long aircraftId,
- long departureAirportId, DateTime departureDate, DateTime arriveDate,
- long arriveAirportId, decimal durationMinutes, DateTime flightDate, Enums.FlightStatus status,
+ public void Delete(Guid id, string flightNumber, Guid aircraftId,
+ Guid departureAirportId, DateTime departureDate, DateTime arriveDate,
+ Guid arriveAirportId, decimal durationMinutes, DateTime flightDate, Enums.FlightStatus status,
decimal price, bool isDeleted = true)
{
FlightNumber = flightNumber;
diff --git a/src/Services/Flight/src/Flight/Flights/Models/FlightReadModel.cs b/src/Services/Flight/src/Flight/Flights/Models/FlightReadModel.cs
index cd51d06..e11c22d 100644
--- a/src/Services/Flight/src/Flight/Flights/Models/FlightReadModel.cs
+++ b/src/Services/Flight/src/Flight/Flights/Models/FlightReadModel.cs
@@ -4,14 +4,14 @@ using System;
public class FlightReadModel
{
- public long Id { get; init; }
- public long FlightId { get; init; }
+ public Guid Id { get; init; }
+ public Guid FlightId { get; init; }
public string FlightNumber { get; init; }
- public long AircraftId { get; init; }
+ public Guid AircraftId { get; init; }
public DateTime DepartureDate { get; init; }
- public long DepartureAirportId { get; init; }
+ public Guid DepartureAirportId { get; init; }
public DateTime ArriveDate { get; init; }
- public long ArriveAirportId { get; init; }
+ public Guid ArriveAirportId { get; init; }
public decimal DurationMinutes { get; init; }
public DateTime FlightDate { get; init; }
public Enums.FlightStatus Status { get; init; }
diff --git a/src/Services/Flight/src/Flight/GrpcServer/Protos/flight.proto b/src/Services/Flight/src/Flight/GrpcServer/Protos/flight.proto
index 549b7d7..aba77c4 100644
--- a/src/Services/Flight/src/Flight/GrpcServer/Protos/flight.proto
+++ b/src/Services/Flight/src/Flight/GrpcServer/Protos/flight.proto
@@ -11,7 +11,7 @@ service FlightGrpcService {
}
message GetByIdRequest {
- int64 Id = 1;
+ string Id = 1;
}
message GetFlightByIdResult{
@@ -23,39 +23,39 @@ repeated SeatDtoResponse SeatDtos = 1;
}
message ReserveSeatResult{
- int64 Id = 1;
+ string Id = 1;
}
message FlightResponse {
- int64 Id = 1;
+ string Id = 1;
string FlightNumber = 2;
- int64 AircraftId = 3;
- int64 DepartureAirportId = 4;
+ string AircraftId = 3;
+ string DepartureAirportId = 4;
google.protobuf.Timestamp DepartureDate = 5;
google.protobuf.Timestamp ArriveDate = 6;
- int64 ArriveAirportId = 7;
+ string ArriveAirportId = 7;
double DurationMinutes = 8;
google.protobuf.Timestamp FlightDate = 9;
FlightStatus Status = 10;
double Price = 11;
- int64 FlightId = 12;
+ string FlightId = 12;
}
message GetAvailableSeatsRequest {
- int64 FlightId = 1;
+ string FlightId = 1;
}
message SeatDtoResponse {
- int64 Id = 1;
+ string Id = 1;
string SeatNumber = 2;
SeatType Type = 3;
SeatClass Class = 4;
- int64 FlightId = 5;
+ string FlightId = 5;
}
message ReserveSeatRequest {
- int64 FlightId = 1;
+ string FlightId = 1;
string SeatNumber = 2;
}
diff --git a/src/Services/Flight/src/Flight/GrpcServer/Services/FlightGrpcServices.cs b/src/Services/Flight/src/Flight/GrpcServer/Services/FlightGrpcServices.cs
index 71c75f0..d67bf57 100644
--- a/src/Services/Flight/src/Flight/GrpcServer/Services/FlightGrpcServices.cs
+++ b/src/Services/Flight/src/Flight/GrpcServer/Services/FlightGrpcServices.cs
@@ -5,6 +5,7 @@ using MediatR;
namespace Flight.GrpcServer.Services;
+using System;
using Flights.Features.GettingFlightById.V1;
using Seats.Features.GettingAvailableSeats.V1;
using Seats.Features.ReservingSeat.Commands.V1;
@@ -23,7 +24,7 @@ public class FlightGrpcServices : FlightGrpcService.FlightGrpcServiceBase
public override async Task GetById(GetByIdRequest request, ServerCallContext context)
{
- var result = await _mediator.Send(new GetFlightById(request.Id));
+ var result = await _mediator.Send(new GetFlightById(new Guid(request.Id)));
return result.Adapt();
}
@@ -31,7 +32,7 @@ public class FlightGrpcServices : FlightGrpcService.FlightGrpcServiceBase
{
var result = new GetAvailableSeatsResult();
- var availableSeats = await _mediator.Send(new GetAvailableSeats(request.FlightId));
+ var availableSeats = await _mediator.Send(new GetAvailableSeats(new Guid(request.FlightId)));
if (availableSeats?.SeatDtos == null)
{
@@ -48,7 +49,7 @@ public class FlightGrpcServices : FlightGrpcService.FlightGrpcServiceBase
public override async Task ReserveSeat(ReserveSeatRequest request, ServerCallContext context)
{
- var result = await _mediator.Send(new ReserveSeat(request.FlightId, request.SeatNumber));
+ var result = await _mediator.Send(new ReserveSeat(new Guid(request.FlightId), request.SeatNumber));
return result.Adapt();
}
}
diff --git a/src/Services/Flight/src/Flight/Seats/Dtos/SeatDto.cs b/src/Services/Flight/src/Flight/Seats/Dtos/SeatDto.cs
index 9fcc68f..0547616 100644
--- a/src/Services/Flight/src/Flight/Seats/Dtos/SeatDto.cs
+++ b/src/Services/Flight/src/Flight/Seats/Dtos/SeatDto.cs
@@ -1,3 +1,5 @@
namespace Flight.Seats.Dtos;
-public record SeatDto(long Id, string SeatNumber, Enums.SeatType Type, Enums.SeatClass Class, long FlightId);
+using System;
+
+public record SeatDto(Guid Id, string SeatNumber, Enums.SeatType Type, Enums.SeatClass Class, Guid FlightId);
diff --git a/src/Services/Flight/src/Flight/Seats/Features/CreatingSeat/V1/CreateSeat.cs b/src/Services/Flight/src/Flight/Seats/Features/CreatingSeat/V1/CreateSeat.cs
index fff3194..5034ad0 100644
--- a/src/Services/Flight/src/Flight/Seats/Features/CreatingSeat/V1/CreateSeat.cs
+++ b/src/Services/Flight/src/Flight/Seats/Features/CreatingSeat/V1/CreateSeat.cs
@@ -1,26 +1,25 @@
namespace Flight.Seats.Features.CreatingSeat.V1;
+using System;
using System.Threading;
using System.Threading.Tasks;
using Ardalis.GuardClauses;
using BuildingBlocks.Core.CQRS;
using BuildingBlocks.Core.Event;
-using BuildingBlocks.IdsGenerator;
using Flight.Data;
-using Flight.Seats.Dtos;
using Flight.Seats.Exceptions;
using Flight.Seats.Models;
using FluentValidation;
-using MapsterMapper;
+using MassTransit;
using MediatR;
using Microsoft.EntityFrameworkCore;
-public record CreateSeat(string SeatNumber, Enums.SeatType Type, Enums.SeatClass Class, long FlightId) : ICommand, IInternalCommand
+public record CreateSeat(string SeatNumber, Enums.SeatType Type, Enums.SeatClass Class, Guid FlightId) : ICommand, IInternalCommand
{
- public long Id { get; init; } = SnowflakeIdGenerator.NewId();
+ public Guid Id { get; init; } = NewId.NextGuid();
}
-public record CreateSeatResult(long Id);
+public record CreateSeatResult(Guid Id);
internal class CreateSeatValidator : AbstractValidator
{
diff --git a/src/Services/Flight/src/Flight/Seats/Features/CreatingSeat/V1/CreateSeatEndpoint.cs b/src/Services/Flight/src/Flight/Seats/Features/CreatingSeat/V1/CreateSeatEndpoint.cs
index 0760d98..fdccb07 100644
--- a/src/Services/Flight/src/Flight/Seats/Features/CreatingSeat/V1/CreateSeatEndpoint.cs
+++ b/src/Services/Flight/src/Flight/Seats/Features/CreatingSeat/V1/CreateSeatEndpoint.cs
@@ -1,5 +1,6 @@
namespace Flight.Seats.Features.CreatingSeat.V1;
+using System;
using System.Threading;
using System.Threading.Tasks;
using BuildingBlocks.Web;
@@ -10,8 +11,8 @@ using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Routing;
using Swashbuckle.AspNetCore.Annotations;
-public record CreateSeatRequestDto(string SeatNumber, Enums.SeatType Type, Enums.SeatClass Class, long FlightId);
-public record CreateSeatResponseDto(long Id);
+public record CreateSeatRequestDto(string SeatNumber, Enums.SeatType Type, Enums.SeatClass Class, Guid FlightId);
+public record CreateSeatResponseDto(Guid Id);
public class CreateSeatEndpoint : IMinimalEndpoint
{
diff --git a/src/Services/Flight/src/Flight/Seats/Features/CreatingSeat/V1/CreateSeatMongo.cs b/src/Services/Flight/src/Flight/Seats/Features/CreatingSeat/V1/CreateSeatMongo.cs
index 6d93f6d..018be0b 100644
--- a/src/Services/Flight/src/Flight/Seats/Features/CreatingSeat/V1/CreateSeatMongo.cs
+++ b/src/Services/Flight/src/Flight/Seats/Features/CreatingSeat/V1/CreateSeatMongo.cs
@@ -1,5 +1,6 @@
namespace Flight.Seats.Features.CreatingSeat.V1;
+using System;
using System.Threading;
using System.Threading.Tasks;
using Ardalis.GuardClauses;
@@ -13,8 +14,8 @@ using MediatR;
using MongoDB.Driver;
using MongoDB.Driver.Linq;
-public record CreateSeatMongo(long Id, string SeatNumber, Enums.SeatType Type,
- Enums.SeatClass Class, long FlightId, bool IsDeleted) : InternalCommand;
+public record CreateSeatMongo(Guid Id, string SeatNumber, Enums.SeatType Type,
+ Enums.SeatClass Class, Guid FlightId, bool IsDeleted) : InternalCommand;
public class CreateSeatMongoHandler : ICommandHandler
{
diff --git a/src/Services/Flight/src/Flight/Seats/Features/CreatingSeat/V1/SeatCreatedDomainEvent.cs b/src/Services/Flight/src/Flight/Seats/Features/CreatingSeat/V1/SeatCreatedDomainEvent.cs
index 3f80f56..1a1e04a 100644
--- a/src/Services/Flight/src/Flight/Seats/Features/CreatingSeat/V1/SeatCreatedDomainEvent.cs
+++ b/src/Services/Flight/src/Flight/Seats/Features/CreatingSeat/V1/SeatCreatedDomainEvent.cs
@@ -1,5 +1,6 @@
namespace Flight.Seats.Features.CreatingSeat.V1;
+using System;
using BuildingBlocks.Core.Event;
-public record SeatCreatedDomainEvent(long Id, string SeatNumber, Enums.SeatType Type, Enums.SeatClass Class, long FlightId, bool IsDeleted) : IDomainEvent;
+public record SeatCreatedDomainEvent(Guid Id, string SeatNumber, Enums.SeatType Type, Enums.SeatClass Class, Guid FlightId, bool IsDeleted) : IDomainEvent;
diff --git a/src/Services/Flight/src/Flight/Seats/Features/GettingAvailableSeats/V1/GetAvailableSeats.cs b/src/Services/Flight/src/Flight/Seats/Features/GettingAvailableSeats/V1/GetAvailableSeats.cs
index 10a6e8c..3c2c07f 100644
--- a/src/Services/Flight/src/Flight/Seats/Features/GettingAvailableSeats/V1/GetAvailableSeats.cs
+++ b/src/Services/Flight/src/Flight/Seats/Features/GettingAvailableSeats/V1/GetAvailableSeats.cs
@@ -1,5 +1,6 @@
namespace Flight.Seats.Features.GettingAvailableSeats.V1;
+using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
@@ -14,7 +15,7 @@ using MapsterMapper;
using MediatR;
using MongoDB.Driver;
-public record GetAvailableSeats(long FlightId) : IQuery;
+public record GetAvailableSeats(Guid FlightId) : IQuery;
public record GetAvailableSeatsResult(IEnumerable SeatDtos);
diff --git a/src/Services/Flight/src/Flight/Seats/Features/GettingAvailableSeats/V1/GetAvailableSeatsEndpoint.cs b/src/Services/Flight/src/Flight/Seats/Features/GettingAvailableSeats/V1/GetAvailableSeatsEndpoint.cs
index 972965a..bd4f15c 100644
--- a/src/Services/Flight/src/Flight/Seats/Features/GettingAvailableSeats/V1/GetAvailableSeatsEndpoint.cs
+++ b/src/Services/Flight/src/Flight/Seats/Features/GettingAvailableSeats/V1/GetAvailableSeatsEndpoint.cs
@@ -1,5 +1,6 @@
namespace Flight.Seats.Features.GettingAvailableSeats.V1;
+using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
@@ -29,7 +30,7 @@ public class GetAvailableSeatsEndpoint : IMinimalEndpoint
return builder;
}
- private async Task GetAvailableSeats(long id, IMediator mediator, CancellationToken cancellationToken)
+ private async Task GetAvailableSeats(Guid id, IMediator mediator, CancellationToken cancellationToken)
{
var result = await mediator.Send(new GetAvailableSeats(id), cancellationToken);
diff --git a/src/Services/Flight/src/Flight/Seats/Features/ReservingSeat/Commands/V1/ReserveSeat.cs b/src/Services/Flight/src/Flight/Seats/Features/ReservingSeat/Commands/V1/ReserveSeat.cs
index d35f679..5cbf019 100644
--- a/src/Services/Flight/src/Flight/Seats/Features/ReservingSeat/Commands/V1/ReserveSeat.cs
+++ b/src/Services/Flight/src/Flight/Seats/Features/ReservingSeat/Commands/V1/ReserveSeat.cs
@@ -1,5 +1,6 @@
namespace Flight.Seats.Features.ReservingSeat.Commands.V1;
+using System;
using System.Threading;
using System.Threading.Tasks;
using Ardalis.GuardClauses;
@@ -11,9 +12,9 @@ using FluentValidation;
using MediatR;
using Microsoft.EntityFrameworkCore;
-public record ReserveSeat(long FlightId, string SeatNumber) : ICommand, IInternalCommand;
+public record ReserveSeat(Guid FlightId, string SeatNumber) : ICommand, IInternalCommand;
-public record ReserveSeatResult(long Id);
+public record ReserveSeatResult(Guid Id);
internal class ReserveSeatValidator : AbstractValidator
{
diff --git a/src/Services/Flight/src/Flight/Seats/Features/ReservingSeat/Commands/V1/ReserveSeatEndpoint.cs b/src/Services/Flight/src/Flight/Seats/Features/ReservingSeat/Commands/V1/ReserveSeatEndpoint.cs
index 3a98d0c..766b3fb 100644
--- a/src/Services/Flight/src/Flight/Seats/Features/ReservingSeat/Commands/V1/ReserveSeatEndpoint.cs
+++ b/src/Services/Flight/src/Flight/Seats/Features/ReservingSeat/Commands/V1/ReserveSeatEndpoint.cs
@@ -1,5 +1,6 @@
namespace Flight.Seats.Features.ReservingSeat.Commands.V1;
+using System;
using System.Threading;
using System.Threading.Tasks;
using BuildingBlocks.Web;
@@ -10,8 +11,8 @@ using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Routing;
using Swashbuckle.AspNetCore.Annotations;
-public record ReserveSeatRequestDto(long FlightId, string SeatNumber);
-public record ReserveSeatResponseDto(long Id);
+public record ReserveSeatRequestDto(Guid FlightId, string SeatNumber);
+public record ReserveSeatResponseDto(Guid Id);
public class ReserveSeatEndpoint : IMinimalEndpoint
{
diff --git a/src/Services/Flight/src/Flight/Seats/Features/ReservingSeat/Commands/V1/ReserveSeatMongo.cs b/src/Services/Flight/src/Flight/Seats/Features/ReservingSeat/Commands/V1/ReserveSeatMongo.cs
index 6377e72..c4eab79 100644
--- a/src/Services/Flight/src/Flight/Seats/Features/ReservingSeat/Commands/V1/ReserveSeatMongo.cs
+++ b/src/Services/Flight/src/Flight/Seats/Features/ReservingSeat/Commands/V1/ReserveSeatMongo.cs
@@ -1,5 +1,6 @@
namespace Flight.Seats.Features.ReservingSeat.Commands.V1;
+using System;
using System.Threading;
using System.Threading.Tasks;
using Ardalis.GuardClauses;
@@ -11,8 +12,8 @@ using MapsterMapper;
using MediatR;
using MongoDB.Driver;
-public record ReserveSeatMongo(long Id, string SeatNumber, Enums.SeatType Type,
- Enums.SeatClass Class, long FlightId, bool IsDeleted) : InternalCommand;
+public record ReserveSeatMongo(Guid Id, string SeatNumber, Enums.SeatType Type,
+ Enums.SeatClass Class, Guid FlightId, bool IsDeleted) : InternalCommand;
internal class ReserveSeatMongoHandler : ICommandHandler
{
diff --git a/src/Services/Flight/src/Flight/Seats/Features/ReservingSeat/Commands/V1/SeatReservedDomainEvent.cs b/src/Services/Flight/src/Flight/Seats/Features/ReservingSeat/Commands/V1/SeatReservedDomainEvent.cs
index 1ccc1a7..f83b721 100644
--- a/src/Services/Flight/src/Flight/Seats/Features/ReservingSeat/Commands/V1/SeatReservedDomainEvent.cs
+++ b/src/Services/Flight/src/Flight/Seats/Features/ReservingSeat/Commands/V1/SeatReservedDomainEvent.cs
@@ -1,5 +1,6 @@
namespace Flight.Seats.Features.ReservingSeat.Commands.V1;
+using System;
using BuildingBlocks.Core.Event;
-public record SeatReservedDomainEvent(long Id, string SeatNumber, Enums.SeatType Type, Enums.SeatClass Class, long FlightId, bool IsDeleted) : IDomainEvent;
+public record SeatReservedDomainEvent(Guid Id, string SeatNumber, Enums.SeatType Type, Enums.SeatClass Class, Guid FlightId, bool IsDeleted) : IDomainEvent;
diff --git a/src/Services/Flight/src/Flight/Seats/Features/SeatMappings.cs b/src/Services/Flight/src/Flight/Seats/Features/SeatMappings.cs
index 4321875..d8a0d56 100644
--- a/src/Services/Flight/src/Flight/Seats/Features/SeatMappings.cs
+++ b/src/Services/Flight/src/Flight/Seats/Features/SeatMappings.cs
@@ -1,4 +1,3 @@
-using BuildingBlocks.IdsGenerator;
using Flight.Seats.Dtos;
using Flight.Seats.Models;
using Mapster;
@@ -6,6 +5,7 @@ using Mapster;
namespace Flight.Seats.Features;
using CreatingSeat.V1;
+using MassTransit;
using ReservingSeat.Commands.V1;
public class SeatMappings : IRegister
@@ -16,11 +16,11 @@ public class SeatMappings : IRegister
.ConstructUsing(x => new SeatDto(x.Id, x.SeatNumber, x.Type, x.Class, x.FlightId));
config.NewConfig()
- .Map(d => d.Id, s => SnowflakeIdGenerator.NewId())
+ .Map(d => d.Id, s => NewId.NextGuid())
.Map(d => d.SeatId, s => s.Id);
config.NewConfig()
- .Map(d => d.Id, s => SnowflakeIdGenerator.NewId())
+ .Map(d => d.Id, s => NewId.NextGuid())
.Map(d => d.SeatId, s => s.Id);
config.NewConfig