コード例 #1
0
        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
            });
        }
コード例 #2
0
 public void HandleEvent(InitializeBooking msg)
 {
     CustomerNumber = msg.CustomerNumber;
     Departure      = msg.Departure;
     Route          = msg.Route;
     BookingStatus  = BookingStatusEnum.Created;
 }
コード例 #3
0
ファイル: BookedFlightService.cs プロジェクト: p0sXke/Test
        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));
        }
コード例 #4
0
 public void HandleEvent(BookingCancelled msg)
 {
     BookingStatus = BookingStatusEnum.Cancelled;
 }
コード例 #5
0
 public void HandleEvent(BookingConfirmed msg)
 {
     BookingStatus = BookingStatusEnum.Confirmed;
 }