@@ -87,7 +87,7 @@ private async Task<TicketDto> BookSingleSeatAsync(AddTicketDto createDto)
8787 }
8888
8989 BookingOrderDto bookingOrder ;
90- if ( createDto . TicketType == TicketTypeEnum . Normal )
90+ if ( createDto . TicketType == TicketTypeEnum . Normal )
9191 {
9292 bookingOrder = await _bookingOrderService . CreateAsync ( new AddBookingOrderDto ( ) ) ;
9393 }
@@ -333,7 +333,7 @@ public async Task<List<TicketDto>> GetTicketWithPassengerInfoAsync(Guid bookingO
333333 {
334334 var request = new GetSeatInformationRequest { SeatId = ticket . TicketSeats . FirstOrDefault ( ) ? . SeatId . ToString ( ) } ;
335335 var seatInformation = await _adminGrpcServiceClient . GetSeatInformationAsync ( request ) ;
336- ticket . SeatInformation = _mapper . Map < Seat > ( seatInformation ) ;
336+ ticket . SeatInformations . Add ( _mapper . Map < Seat > ( seatInformation ) ) ;
337337 }
338338 return tickets ;
339339 }
@@ -344,6 +344,12 @@ public Task<TicketDto> GetTicketByTicketNumberAsync(string ticketNumber)
344344 return GetTicketAsync ( specification ) ;
345345 }
346346
347+ public override Task < TicketDto > GetByIdAsync ( Guid ticketId )
348+ {
349+ var specification = new TicketIdSpecification ( ticketId ) ;
350+ return GetTicketAsync ( specification ) ;
351+ }
352+
347353 private async Task < TicketDto > GetTicketAsync ( Specification < Ticket > specification )
348354 {
349355 var includes = new List < Expression < Func < Ticket , object > > >
@@ -355,9 +361,13 @@ private async Task<TicketDto> GetTicketAsync(Specification<Ticket> specification
355361 var ticket = await _bookingUnitOfWork . TicketRepository
356362 . FirstOrDefaultAsync ( specification , includes ) ;
357363 var ticketDto = _mapper . Map < TicketDto > ( ticket ) ;
358- var request = new GetSeatInformationRequest { SeatId = ticket . TicketSeats . FirstOrDefault ( ) . SeatId . ToString ( ) } ;
359- var seatInformation = await _adminGrpcServiceClient . GetSeatInformationAsync ( request ) ;
360- ticketDto . SeatInformation = _mapper . Map < Seat > ( seatInformation ) ;
364+ var seatInformation = new List < Seat > ( ) ;
365+ foreach ( var ticketSeat in ticket . TicketSeats )
366+ {
367+ var request = new GetSeatInformationRequest { SeatId = ticketSeat . SeatId . ToString ( ) } ;
368+ var seat = await _adminGrpcServiceClient . GetSeatInformationAsync ( request ) ;
369+ seatInformation . Add ( _mapper . Map < Seat > ( seatInformation ) ) ;
370+ }
361371 return ticketDto ;
362372 }
363373
@@ -406,6 +416,10 @@ public async Task<double> GetTicketPricesByBookingOrderAsync(Guid bookingOrderId
406416 return tickets . Sum ( t => ( double ) t . TotalPrice ) ;
407417 }
408418
409- public Task CancelTicketAsync ( Guid ticketId ) => throw new NotImplementedException ( ) ;
419+ public async Task CancelTicketAsync ( Guid ticketId )
420+ {
421+ var ticket = await _bookingUnitOfWork . TicketRepository . GetByIdAsync ( ticketId ) ;
422+ ticket . Status = TicketStatusEnum . Cancelled ;
423+ }
410424 }
411425}
0 commit comments