/// <summary> /// This method sets Check In/Out status of a confirmed booking. /// </summary> /// <param name="booking">booking to check in / out</param> /// <param name="checkinStatus">check in status code to change booking to</param> /// <param name="cultureCode">Culture code</param> /// <returns>The updated booking as the check in details are required for the UI.</returns> public Model.Booking.Booking CheckInCheckOutBooking(Model.Booking.Booking booking, EnumEntity checkinStatus, string cultureCode = "") { DateTime? checkinDate, checkoutDate; switch (checkinStatus.Code) { case CheckinStatusOptions.CHECKEDIN: checkinDate = DateTime.Now; checkoutDate = null; break; case CheckinStatusOptions.CHECKEDOUT: checkinDate = booking.EffectiveCheckInDateLT ?? DateTime.Now; checkoutDate = DateTime.Now; break; case CheckinStatusOptions.NOTCHECKEDIN: default: checkinDate = null; checkoutDate = null; break; } var parameters = new List<SqlParameter>(); parameters.Add(DbHelper.CreateParameter(BookingMapper.Parameters.Id, booking.Id)); parameters.Add(DbHelper.CreateParameter(BookingMapper.Parameters.CheckInStatusCode, checkinStatus.Code)); // Add auditing parameters AuditFieldsHelper.PopulateAuditFields(parameters); int rowsAffected = DbHelper.ExecuteNonQueryCommand("Booking.CheckInCheckOutBooking", CommandType.StoredProcedure, parameters); // Check if the update was successful if (rowsAffected > 0) { // Update Checkin / Checkout status of the booking booking.EffectiveCheckInDateLT = checkinDate; booking.EffectiveCheckOutDateLT = checkoutDate; booking.CheckinStatus = checkinStatus; return booking; } throw new ExpectedResultException(ErrorFactory.CreateAndLogError(Errors.SRVEX30027, "BookingDao.CheckInCheckOutBooking", additionalDescriptionParameters: (new object[] { typeof(Model.Booking.Booking).Name, booking.Id }), arguments: new object[] { typeof(Model.Booking.Booking).Name, booking.Id })); }
/// <summary> /// Set up booking for scenario given a row from feature table /// </summary> /// <param name="bookingType">booking type column cell</param> /// <param name="currentRoomType">room type</param> /// <param name="row">row from feature table</param> /// <param name="userId">user to use for created by</param> /// <returns>Booking to use</returns> private Booking SetUpBooking(string bookingType, RoomType currentRoomType, TableRow row, Guid userId) { int randomGuestId = TestSchemaHelper.LoadRandomGuest(businesses[row[HOTEL]], userId); EnumEntity bookingStatus = new EnumEntity { Code = bookingType.ToLower().IndexOf("confirmed") >= 0 ? BookingStatusType.CONFIRMED : BookingStatusType.PROVISIONAL }; return new Booking { BusinessId = businesses[row[HOTEL]], RoomId = currentRoomType.Rooms.Find(rm => rm.Name == row[ROOM_NAME]).Id, RoomTypeId = currentRoomType.Id, RatePlanId = currentRoomType.BaseRatePlans[0].Id, // Assume first rate plan for room type since not specified in given StartDate = GetDateFromFeatureString(row[START_DATE]), EndDate = GetDateFromFeatureString(row[END_DATE]), BookingStatus = bookingStatus, Guest = new Model.Customer.Guest { Id = randomGuestId }, BookingScenarioType = BookingScenarioTypeEnum.OnAccountBooking, CurrencyCode = "GBP", SourceType = new EnumEntity { Code = SourceType.ONLINE }, RateType = new EnumEntity { Code = RateType.BEST_AVAILABLE_RATE }, CheckinStatus = new EnumEntity { Code = CheckinStatusOptions.NOTCHECKEDIN }, Cost = 1 }; }
/// <summary> /// Map BookingStatus to settlement ReservationStatusTypes /// </summary> /// <param name="bookingStatus">bookingStatus</param> /// <returns>ReservationStatusTypes</returns> private ReservationStatusTypes MapToSettlementTransactionReservationStatusTypes(EnumEntity bookingStatus) { switch (bookingStatus.Code) { case BookingStatusType.CANCELLED: return ReservationStatusTypes.Confirmed_Cancelled; case BookingStatusType.LAPSED: return ReservationStatusTypes.Cancelled; case BookingStatusType.CONFIRMED: return ReservationStatusTypes.Confirmed; default: return ReservationStatusTypes.Unknown; } }