mirror of
https://github.com/meysamhadeli/booking-microservices.git
synced 2026-04-16 07:26:25 +08:00
remove logical isDeleted and use global query instead
This commit is contained in:
parent
1ed1fb3339
commit
1c6bf65c65
@ -30,7 +30,7 @@ public class BookingProjection : IProjectionProcessor
|
||||
private async Task Apply(BookingCreatedDomainEvent @event, CancellationToken cancellationToken = default)
|
||||
{
|
||||
var reservation =
|
||||
await _bookingDbContext.Bookings.SingleOrDefaultAsync(x => x.Id == @event.Id && !x.IsDeleted,
|
||||
await _bookingDbContext.Bookings.SingleOrDefaultAsync(x => x.Id == @event.Id,
|
||||
cancellationToken);
|
||||
|
||||
if (reservation == null)
|
||||
|
||||
@ -31,7 +31,7 @@ public class CreateFlightCommandHandler : ICommandHandler<CreateFlightCommand, F
|
||||
{
|
||||
Guard.Against.Null(command, nameof(command));
|
||||
|
||||
var flight = await _flightDbContext.Flights.SingleOrDefaultAsync(x => x.Id == command.Id && !x.IsDeleted,
|
||||
var flight = await _flightDbContext.Flights.SingleOrDefaultAsync(x => x.Id == command.Id,
|
||||
cancellationToken);
|
||||
|
||||
if (flight is not null)
|
||||
|
||||
@ -29,7 +29,7 @@ public class GetAvailableFlightsQueryHandler : IQueryHandler<GetAvailableFlights
|
||||
{
|
||||
Guard.Against.Null(query, nameof(query));
|
||||
|
||||
var flight = await _flightDbContext.Flights.Where(x => !x.IsDeleted).ToListAsync(cancellationToken);
|
||||
var flight = await _flightDbContext.Flights.ToListAsync(cancellationToken);
|
||||
|
||||
if (!flight.Any())
|
||||
throw new FlightNotFountException();
|
||||
|
||||
@ -27,7 +27,7 @@ public class GetFlightByIdQueryHandler : IQueryHandler<GetFlightByIdQuery, Fligh
|
||||
Guard.Against.Null(query, nameof(query));
|
||||
|
||||
var flight =
|
||||
await _flightDbContext.Flights.SingleOrDefaultAsync(x => x.Id == query.Id && !x.IsDeleted, cancellationToken);
|
||||
await _flightDbContext.Flights.SingleOrDefaultAsync(x => x.Id == query.Id, cancellationToken);
|
||||
|
||||
if (flight is null)
|
||||
throw new FlightNotFountException();
|
||||
|
||||
@ -28,7 +28,7 @@ public class UpdateFlightCommandHandler : ICommandHandler<UpdateFlightCommand, F
|
||||
{
|
||||
Guard.Against.Null(command, nameof(command));
|
||||
|
||||
var flight = await _flightDbContext.Flights.SingleOrDefaultAsync(x => x.Id == command.Id && !x.IsDeleted,
|
||||
var flight = await _flightDbContext.Flights.SingleOrDefaultAsync(x => x.Id == command.Id,
|
||||
cancellationToken);
|
||||
|
||||
if (flight is null)
|
||||
|
||||
@ -31,7 +31,7 @@ public class CreateSeatCommandHandler : IRequestHandler<CreateSeatCommand, SeatR
|
||||
{
|
||||
Guard.Against.Null(command, nameof(command));
|
||||
|
||||
var seat = await _flightDbContext.Seats.SingleOrDefaultAsync(x => x.Id == command.Id && !x.IsDeleted, cancellationToken);
|
||||
var seat = await _flightDbContext.Seats.SingleOrDefaultAsync(x => x.Id == command.Id, cancellationToken);
|
||||
|
||||
if (seat is not null)
|
||||
throw new SeatAlreadyExistException();
|
||||
|
||||
@ -28,7 +28,7 @@ public class GetAvailableSeatsQueryHandler : IRequestHandler<GetAvailableSeatsQu
|
||||
{
|
||||
Guard.Against.Null(query, nameof(query));
|
||||
|
||||
var seats = await _flightDbContext.Seats.Where(x => x.FlightId == query.FlightId && !x.IsDeleted).ToListAsync(cancellationToken);
|
||||
var seats = await _flightDbContext.Seats.Where(x => x.FlightId == query.FlightId).ToListAsync(cancellationToken);
|
||||
|
||||
if (!seats.Any())
|
||||
throw new AllSeatsFullException();
|
||||
|
||||
@ -25,8 +25,7 @@ public class ReserveSeatCommandHandler : IRequestHandler<ReserveSeatCommand, Sea
|
||||
{
|
||||
Guard.Against.Null(command, nameof(command));
|
||||
|
||||
var seat = await _flightDbContext.Seats.SingleOrDefaultAsync(x => x.SeatNumber == command.SeatNumber && x.FlightId == command.FlightId
|
||||
&& !x.IsDeleted, cancellationToken);
|
||||
var seat = await _flightDbContext.Seats.SingleOrDefaultAsync(x => x.SeatNumber == command.SeatNumber && x.FlightId == command.FlightId, cancellationToken);
|
||||
|
||||
if (seat is null)
|
||||
throw new SeatNumberIncorrectException();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user