/// <summary> /// Updates a reservation and sets the status to confirmed. /// </summary> /// <param name="reservationRequest">Reservation request</param> /// <param name="profileServiceClient">Profile service client</param> /// <returns></returns> public ReservationResponse UpdateReservation(ReservationRequest reservationRequest, IProfileServiceClient profileServiceClient) { using (Profiler.Step("ReservationServiceClient.UpdateReservation")) { var activityId = String.Empty; try { var header = ContextListBuilder.New().WithBusinessContext(ContextListAppContextSourceBusinessContext.VA) .WithUserId(reservationRequest.UserUniqueId.ToString()) .Build(); activityId = header.DiagnosticContext.ActivityId; var profileRequest = new ProfileRequest { ChainId = reservationRequest.ChainId, HotelId = reservationRequest.HotelId, TravelerProfileId = reservationRequest.GuestProfileId }; var guestProfile = profileServiceClient.GetTravelerProfile(profileRequest); using (var itineraryManagerClient = new ItineraryManagerClient(header, ServiceRegistry.AddressPool.OfType<IItineraryManager>())) { var updateReservationRq = new UpdateReservationRQ { Reservation = CreateUpdateReservationRequest(reservationRequest, guestProfile), ReturnReservationDetails = true, UserDetails = new UpdateReservationRQUserDetails { Preferences = new UpdateReservationRQUserDetailsPreferences { Language = new Language { Code = reservationRequest.Language } } } }; var updateReservationResponse = itineraryManagerClient.UpdateReservation(updateReservationRq); var reservationResponse = new ReservationResponse { ApplicationResults = new ApplicationResultsModel( updateReservationResponse.ApplicationResults.Success.IfNotNull(result => result.SystemSpecificResults.ShortText.Equals("Success"), false), updateReservationResponse.ApplicationResults.Warning.IfNotNull( applicationResultWarning => applicationResultWarning.Select(warning => warning.SystemSpecificResults.ShortText), new List<String>()), updateReservationResponse.ApplicationResults.Error.IfNotNull(applicationResultError => applicationResultError.Select(error => error.SystemSpecificResults.ShortText), new List<String>())) }; if (reservationResponse.ApplicationResults.Success) { reservationResponse.Reservation = MapReservationResponse(updateReservationResponse.ReservationList.Reservation); } return reservationResponse; } } catch (Exception exception) { Logger.AppLogger.Error( "UpdateReservationUnhandledException", exception, "ChainId".ToKvp(reservationRequest.ChainId), "HotelId".ToKvp(reservationRequest.HotelId), "UserId".ToKvp(reservationRequest.UserUniqueId)); throw HttpResponseExceptionHelper.CreateHttpResponseException(activityId, exception); } } }
/// <summary> /// Gets a response for a cancel reservation request by confirmation number from ESS reservation manager service. /// </summary> /// <param name="cancelReservationRequest">Cancel Reservation Request</param> /// <returns>CancelReservationResponse</returns> public CancelReservationResponse CancelReservation(CancelReservationRequest cancelReservationRequest) { using (Profiler.Step("ReservationServiceClient.CancelReservation")) { var activityId = String.Empty; try { var header = ContextListBuilder.New().WithBusinessContext(ContextListAppContextSourceBusinessContext.VA) .WithUserId(cancelReservationRequest.UserUniqueId.ToString()) .Build(); activityId = header.DiagnosticContext.ActivityId; using (var itineraryManagerClient = new ItineraryManagerClient(header, ServiceRegistry.AddressPool.OfType<IItineraryManager>())) { var cancelReservationRQ = new CancelReservationRQ { Reservation = new CancelReservationRQReservation { CRS_confirmationNumber = cancelReservationRequest.CrsConfirmationNumber }, UserDetails = new CancelReservationRQUserDetails { Preferences = new CancelReservationRQUserDetailsPreferences { Language = new Language { Code = WebConstants.DefaultLanguage } } } }; var cancelReservationResponse = itineraryManagerClient.CancelReservation(cancelReservationRQ); var cancelReservationResultResponse = new CancelReservationResponse { ApplicationResults = new ApplicationResultsModel( cancelReservationResponse.ApplicationResults.Success.IsNotNull(), cancelReservationResponse.ApplicationResults.Warning.IfNotNull( w => w.Select( warning => warning.SystemSpecificResults.ShortText)), cancelReservationResponse.ApplicationResults.Error.IfNotNull( e => e.Select(error => error.SystemSpecificResults.ShortText) )), CrsConfirmationNumber = cancelReservationResponse.Reservation.CRS_confirmationNumber, CancellationNumber = cancelReservationResponse.Reservation.CRS_cancellationNumber }; return cancelReservationResultResponse; } } catch (Exception exception) { Logger.AppLogger.Error( "CancelReservationUnhandledException", exception, "UserId".ToKvp(cancelReservationRequest.UserUniqueId), "CrsConfirmationNumber".ToKvp(cancelReservationRequest.CrsConfirmationNumber)); throw HttpResponseExceptionHelper.CreateHttpResponseException(activityId, exception); } } }
/// <summary> /// Gets a reservation by confirmation number from ESS reservation manager service. /// </summary> /// <param name="reservationRequest">Reservation Request</param> /// <returns>ReservationSearchResult</returns> public ReservationResponse GetReservationSearchResult(ReservationRequest reservationRequest) { using (Profiler.Step("ReservationServiceClient.GetReservationSearchResult")) { var activityId = String.Empty; try { var header = ContextListBuilder.New().WithBusinessContext(ContextListAppContextSourceBusinessContext.VA) .WithUserId(reservationRequest.UserUniqueId.ToString()) .Build(); activityId = header.DiagnosticContext.ActivityId; if (reservationRequest.SearchItemType.IsNullOrEmpty() || reservationRequest.SearchItemValue.IsNullOrEmpty()) return null; QueryReservationRQQueryType queryType; switch (reservationRequest.SearchItemType) { case "email": queryType = QueryReservationRQQueryType.CRS_ConfirmationNumberAndGuestEmail; break; default: queryType = QueryReservationRQQueryType.CRS_ConfirmationNumber; break; } using (var itineraryManagerClient = new ItineraryManagerClient(header, ServiceRegistry.AddressPool.OfType<IItineraryManager>())) { var queryReservationResponse = itineraryManagerClient.QueryReservation(CreateReservationQueryRequest(queryType, reservationRequest.ChainId, reservationRequest.SearchItemValue)); var rez = queryReservationResponse.ReservationList.FirstOrDefault(); return new ReservationResponse { ApplicationResults = new ApplicationResultsModel( queryReservationResponse.ApplicationResults.Success.IsNotNull(), queryReservationResponse.ApplicationResults.Warning.IfNotNull( w => w.Select( warning => warning.SystemSpecificResults.ShortText), queryReservationResponse.ApplicationResults.Error.IfNotNull( e => e.Select(error => error.SystemSpecificResults.ShortText)) )), Reservation = MapReservationResponse(rez) }; } } catch (Exception exception) { Logger.AppLogger.Error( "GetReservationSearchResultUnhandledException", exception, "SearchItemType".ToKvp(reservationRequest.SearchItemType), "SearchItemValue".ToKvp(reservationRequest.SearchItemValue), "ChainId".ToKvp(reservationRequest.ChainId), "HotelId".ToKvp(reservationRequest.HotelId), "UserId".ToKvp(reservationRequest.UserUniqueId)); throw HttpResponseExceptionHelper.CreateHttpResponseException(activityId, exception); } } }