public static Booking Booking(BookingPostModel book) { BookingStatusEnum status = Models.BookingStatusEnum.New; if (book.BookingStatus == "") { status = Models.BookingStatusEnum.New; } else if (book.BookingStatus == "Confirmed") { status = Models.BookingStatusEnum.Confirmed; } else if (book.BookingStatus == "Pending") { status = Models.BookingStatusEnum.Pending; } else { status = Models.BookingStatusEnum.Canceled; } return(new Booking { RoomID = book.RoomID, UserID = book.UserID, BookingStatus = status, PersNumber = book.PersNumber, StartDate = book.StartDate, EndDate = book.EndDate, AddedOn = book.AddedOn, UpdatedOn = book.UpdatedOn }); }
public void HandleEvent(InitializeBooking msg) { CustomerNumber = msg.CustomerNumber; Departure = msg.Departure; Route = msg.Route; BookingStatus = BookingStatusEnum.Created; }
public async Task <BookedFlightDto> ChangeBookingStatus(int id, BookingStatusEnum bookingStatus) { var existing = await _repository.GetAsync(id); if (existing == null) { throw new Exception("Booking with given id not found"); } var flight = await _flightRepository.GetAsync(existing.FlightId); switch (bookingStatus) { case BookingStatusEnum.Approved: if (existing.BookingStatusId != (int)BookingStatusEnum.Approved) { if (flight.SeatNumber - existing.BookSeats >= 0) { flight.SeatNumber -= existing.BookSeats; existing.BookingStatusId = (int)bookingStatus; await _flightRepository.UpdateAsync(flight); await _repository.UpdateAsync(existing); } else { throw new Exception("Number of booked seat exceeds the limit"); } } break; case BookingStatusEnum.Rejected: if (existing.BookingStatusId == (int)BookingStatusEnum.Approved) { flight.SeatNumber += existing.BookSeats; await _flightRepository.UpdateAsync(flight); } existing.BookingStatusId = (int)bookingStatus; await _repository.UpdateAsync(existing); break; default: break; } return(_mapper.Map <BookedFlightDto>(existing)); }
public void HandleEvent(BookingCancelled msg) { BookingStatus = BookingStatusEnum.Cancelled; }
public void HandleEvent(BookingConfirmed msg) { BookingStatus = BookingStatusEnum.Confirmed; }