Example #1
0
        public async Task <dto.CheckInPassengersResponse> Checkin(dto.CheckInPassengersRequestData requestData)
        {
            var booking = await _sessionBag.Booking();

            foreach (var req in requestData.CheckInMultiplePassengerRequestList)
            {
                var segment = booking.Journeys[req.JourneyIndex].Segments[req.SegmentIndex];
                req.RecordLocator   = booking.RecordLocator;
                req.InventoryLegKey = new dto.InventoryLegKey
                {
                    ArrivalStation   = segment.ArrivalStation,
                    DepartureStation = segment.DepartureStation,
                    CarrierCode      = segment.FlightDesignator.CarrierCode,
                    FlightNumber     = segment.FlightDesignator.FlightNumber,
                    OpSuffix         = segment.FlightDesignator.OpSuffix,
                    DepartureDate    = segment.STD
                };
                req.InventoryLegKeyDepartureDateTime = segment.STD;
                var list = new List <dto.CheckInPaxRequest>();
                foreach (var paxNum in req.PassengerNumbers)
                {
                    var bookingPax = Array.Find(booking.Passengers, p => p.PassengerNumber == paxNum);
                    var paxName    = bookingPax.Names[0];
                    list.Add(new dto.CheckInPaxRequest
                    {
                        PassengerNumber = paxNum,
                        Name            = new dto.Name
                        {
                            Title      = paxName.Title,
                            FirstName  = paxName.FirstName,
                            LastName   = paxName.LastName,
                            MiddleName = null
                        }
                    });
                }
                req.CheckInPaxRequestList = list.ToArray();
            }
            var mappedRequest = Mapper.Map <nskop.CheckInPassengersRequestData>(requestData);
            var response      = await _client.CheckInPassengersAsync(new CheckInPassengersRequest
            {
                ContractVersion           = _navApiContractVer,
                EnableExceptionStackTrace = false,
                MessageContractVersion    = _navMsgContractVer,
                Signature = await _sessionBag.Signature(),
                CheckInMultiplePassengersRequest = mappedRequest
            });

            var errorList = from checkInMultiplePassengersResponse in response.CheckInPassengersResponseData.CheckInMultiplePassengerResponseList.ToList()
                            from checkinResponse in checkInMultiplePassengersResponse.CheckInPaxResponseList.ToList()
                            where checkinResponse.ErrorList != null && checkinResponse.ErrorList.Length > 0
                            select checkinResponse.ErrorList.ToList();

            if (errorList != null && errorList.Count() > 0)
            {
                var errorMsgs = new List <string>();
                foreach (var err in errorList)
                {
                    err.ForEach(m => errorMsgs.Add(m.ErrorMessage));
                }
                throw new ResponseErrorException(dto.Enumerations.ResponseErrorCode.CheckInFailure, errorMsgs.ToArray());
            }

            return(Mapper.Map <dto.CheckInPassengersResponse>(response));
        }
 public async Task <IActionResult> Post([FromBody] dto.CheckInPassengersRequestData checkInPassengersRequestData)
 {
     return(new OkObjectResult(await _checkinService.Checkin(checkInPassengersRequestData)));
 }