remove logical isDeleted and use global query instead

This commit is contained in:
meysamhadeli 2022-06-23 00:58:56 +04:30
parent 1ed1fb3339
commit 1c6bf65c65
8 changed files with 8 additions and 9 deletions

View File

@ -30,7 +30,7 @@ public class BookingProjection : IProjectionProcessor
private async Task Apply(BookingCreatedDomainEvent @event, CancellationToken cancellationToken = default) private async Task Apply(BookingCreatedDomainEvent @event, CancellationToken cancellationToken = default)
{ {
var reservation = var reservation =
await _bookingDbContext.Bookings.SingleOrDefaultAsync(x => x.Id == @event.Id && !x.IsDeleted, await _bookingDbContext.Bookings.SingleOrDefaultAsync(x => x.Id == @event.Id,
cancellationToken); cancellationToken);
if (reservation == null) if (reservation == null)

View File

@ -31,7 +31,7 @@ public class CreateFlightCommandHandler : ICommandHandler<CreateFlightCommand, F
{ {
Guard.Against.Null(command, nameof(command)); 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); cancellationToken);
if (flight is not null) if (flight is not null)

View File

@ -29,7 +29,7 @@ public class GetAvailableFlightsQueryHandler : IQueryHandler<GetAvailableFlights
{ {
Guard.Against.Null(query, nameof(query)); 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()) if (!flight.Any())
throw new FlightNotFountException(); throw new FlightNotFountException();

View File

@ -27,7 +27,7 @@ public class GetFlightByIdQueryHandler : IQueryHandler<GetFlightByIdQuery, Fligh
Guard.Against.Null(query, nameof(query)); Guard.Against.Null(query, nameof(query));
var flight = 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) if (flight is null)
throw new FlightNotFountException(); throw new FlightNotFountException();

View File

@ -28,7 +28,7 @@ public class UpdateFlightCommandHandler : ICommandHandler<UpdateFlightCommand, F
{ {
Guard.Against.Null(command, nameof(command)); 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); cancellationToken);
if (flight is null) if (flight is null)

View File

@ -31,7 +31,7 @@ public class CreateSeatCommandHandler : IRequestHandler<CreateSeatCommand, SeatR
{ {
Guard.Against.Null(command, nameof(command)); 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) if (seat is not null)
throw new SeatAlreadyExistException(); throw new SeatAlreadyExistException();

View File

@ -28,7 +28,7 @@ public class GetAvailableSeatsQueryHandler : IRequestHandler<GetAvailableSeatsQu
{ {
Guard.Against.Null(query, nameof(query)); 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()) if (!seats.Any())
throw new AllSeatsFullException(); throw new AllSeatsFullException();

View File

@ -25,8 +25,7 @@ public class ReserveSeatCommandHandler : IRequestHandler<ReserveSeatCommand, Sea
{ {
Guard.Against.Null(command, nameof(command)); Guard.Against.Null(command, nameof(command));
var seat = await _flightDbContext.Seats.SingleOrDefaultAsync(x => x.SeatNumber == command.SeatNumber && x.FlightId == command.FlightId var seat = await _flightDbContext.Seats.SingleOrDefaultAsync(x => x.SeatNumber == command.SeatNumber && x.FlightId == command.FlightId, cancellationToken);
&& !x.IsDeleted, cancellationToken);
if (seat is null) if (seat is null)
throw new SeatNumberIncorrectException(); throw new SeatNumberIncorrectException();