private async Task ValidateTravelDocsAtYakeen(Dictionary <string, string> settings, UpdatePassengersRequestData requestData, ActionExecutingContext context, ISessionBagService sessionBag, Booking booking, Passenger[] passengers) { if (settings == null) { return; } if (!settings.ContainsKey("YakeenCheckEnabled") || string.IsNullOrEmpty(settings["YakeenCheckEnabled"])) { return; } bool.TryParse(settings["YakeenCheckEnabled"], out bool yakeenCheckEnabled); if (!yakeenCheckEnabled) { return; } if (!settings.ContainsKey("YakeenMaxFailures") || string.IsNullOrEmpty(settings["YakeenMaxFailures"]) || !settings.ContainsKey("YakeenServiceUrl") || string.IsNullOrEmpty(settings["YakeenServiceUrl"]) || !settings.ContainsKey("YakeenTimeoutSeconds") || string.IsNullOrEmpty(settings["YakeenTimeoutSeconds"]) || !settings.ContainsKey("YakeenUsername") || string.IsNullOrEmpty(settings["YakeenUsername"]) || !settings.ContainsKey("YakeenPassword") || string.IsNullOrEmpty(settings["YakeenPassword"]) || !settings.ContainsKey("YakeenChargeCode") || string.IsNullOrEmpty(settings["YakeenChargeCode"]) || !settings.ContainsKey("YakeenExcessiveTimeoutCount") || string.IsNullOrEmpty(settings["YakeenExcessiveTimeoutCount"]) || !settings.ContainsKey("YakeenExcessiveTimeoutPeriodSeconds") || string.IsNullOrEmpty(settings["YakeenExcessiveTimeoutPeriodSeconds"]) || !settings.ContainsKey("YakeenExcessiveTimeoutRestSeconds") || string.IsNullOrEmpty(settings["YakeenExcessiveTimeoutRestSeconds"])) { throw new ResponseErrorException(ResponseErrorCode.InternalException, "Missing document validation settings. "); } var cache = context.HttpContext.RequestServices.GetService(typeof(IMemoryCache)) as IMemoryCache; var comments = await sessionBag.PostCommitBookingComments(); var invalid = false; foreach (var pax in passengers) { if (pax.PassengerTravelDocuments != null) { foreach (var doc in pax.PassengerTravelDocuments) { try { await ValidateTravelDoc(doc, booking, pax.PassengerInfo.Nationality, comments, sessionBag, settings, cache); } catch { invalid = true; } } } } if (invalid) { throw new ResponseErrorException(ResponseErrorCode.TravelDocumentValidationFailure, "Unable to validate travel document. Please try again. "); } }
public async Task <IActionResult> Post([FromBody] UpdatePassengersRequestData requestData) { return(new OkObjectResult(await _passengersService.UpdatePassengers(requestData))); }