Ejemplo n.º 1
0
        public ActionResult BookVe(BookModel model)
        {
            try
            {
                //using (var sessionService = new SessionService())
                //{
                var sessionService = new SessionService();
                var tokenModel     = new TokenModel();
                var _session       = sessionService.GetSession();
                if (_session == null)
                {
                    return(null);
                }
                // get token
                string _token          = _session.Token;
                string _conversationId = _session.ConversationID;
                if (string.IsNullOrWhiteSpace(_token))
                {
                    return(null);
                }

                //tokenModel = wss.CreateSession();
                var airBookModel = new AirBookModel
                {
                    ConversationID = _conversationId,
                    Token          = _token
                };

                //- SessionCreateRQ
                //- OTA_AirBookLLSRQ
                //- OTA_AirPriceLLSRQ
                //- PassengerDetailsRQ
                //- EndTransactionLLSRQ
                //- SessionCloseRQ
                //seach data in web service
                List <AirBookModelSegment> airBookModelSegments = new List <AirBookModelSegment>();
                AirBookModelSegment        airBookModelSegmen   = new AirBookModelSegment();

                // #1. flight information - ***********************************************************************************************************************************
                VNAWSOTA_AirBookLLSRQSevice vNAWSOTA_AirBookLLSRQSevice = new VNAWSOTA_AirBookLLSRQSevice();
                List <AirBookModelSegment>  lstSegments = model.lFlight;
                if (lstSegments == null || lstSegments.Count == 0)
                {
                    return(Notifization.Invalid(NotifizationText.Invalid));
                }
                //
                AIRService.WebService.WSOTA_AirBookLLSRQ.OTA_AirBookRS oTA_AirBookRS = vNAWSOTA_AirBookLLSRQSevice.FUNC_OTA_AirBookRS(new AirBookModel
                {
                    Segments       = lstSegments,
                    ConversationID = _conversationId,
                    Token          = _token
                });
                //
                if (oTA_AirBookRS.ApplicationResults.Success == null)
                {
                    return(Notifization.Invalid(NotifizationText.Invalid));
                }
                //
                var _originDestinationOption = oTA_AirBookRS.OriginDestinationOption.ToList();
                if (_originDestinationOption.Count == 0)
                {
                    return(Notifization.NotFound(NotifizationText.NotFound));
                }
                // #2. Get price - ***************************************************************************************************************************************************
                airBookModel.Segments = model.lFlight;
                var airPriceModel = new AirPriceModel
                {
                    ConversationID = _conversationId,
                    Token          = _token,
                    lFlight        = model.lFlight
                };
                foreach (var item in model.lPassenger)
                {
                    if (item.PassengerType.ToUpper() == "ADT")
                    {
                        airPriceModel.ADT++;
                        continue;
                    }
                    if (item.PassengerType.ToUpper() == "CNN")
                    {
                        airPriceModel.CNN++;
                        continue;
                    }
                    if (item.PassengerType.ToUpper() == "INF")
                    {
                        airPriceModel.INF++;
                        continue;
                    }
                }
                VNAWSOTA_AirPriceLLSRQService vNAWSOTA_AirPriceLLSRQService = new VNAWSOTA_AirPriceLLSRQService();
                var airPriceData = vNAWSOTA_AirPriceLLSRQService.AirPrice(airPriceModel);
                //
                if (airPriceData.ApplicationResults.Success == null)
                {
                    return(Notifization.Invalid(NotifizationText.Invalid));
                }
                // #3. Get PNA code - **************************************************************************************************************************************************
                var result = new BookVeResult
                {
                    lPricingInPNR = new List <PricingInPNR>()
                };
                foreach (var item in airPriceData.PriceQuote.PricedItinerary.AirItineraryPricingInfo)
                {
                    foreach (var iter in model.lPassenger.Where(m => m.PassengerType.ToUpper().Equals(item.PassengerTypeQuantity.Code)))
                    {
                        var price = new PricingInPNR
                        {
                            DateOfBirth = iter.DateOfBirth,
                            SurName     = iter.Surname,
                            GivenName   = iter.GivenName,
                            type        = iter.PassengerType.ToUpper(),
                            Fare        = double.Parse(item.ItinTotalFare.BaseFare.Amount)
                        };
                        foreach (var tax in item.ItinTotalFare.Taxes.Tax)
                        {
                            if (tax.TaxCode.Equals("YRI"))
                            {
                                price.ServiceFee = double.Parse(tax.Amount);
                            }
                            if (tax.TaxCode.Equals("UE3"))
                            {
                                price.TaxFee = double.Parse(tax.Amount);
                            }
                            if (tax.TaxCode.Equals("AX"))
                            {
                                price.VAT = double.Parse(tax.Amount);
                            }
                            if (tax.TaxCode.Equals("C4"))
                            {
                                price.ScanFee = double.Parse(tax.Amount);
                            }
                        }
                        result.lPricingInPNR.Add(price);
                    }
                }
                result.Total     = double.Parse(airPriceData.PriceQuote.PricedItinerary.TotalAmount);
                model.lPassenger = model.lPassenger.OrderBy(m => m.PassengerType).ToList();
                // create model passenger details model
                var passengerDetailModel = new PassengerDetailsModel
                {
                    ContactEmail   = model.ContactEmail,
                    ConversationID = _conversationId,
                    Token          = _token,
                    lPassenger     = model.lPassenger,
                    AirBook        = oTA_AirBookRS
                };
                // call service  passenger details in ws.service
                VNAWSPassengerDetailsRQService vNAWSPassengerDetailsRQService = new VNAWSPassengerDetailsRQService();
                AIRService.WebService.WSPassengerDetailsRQ.PassengerDetailsRS passengerDetailsRS = vNAWSPassengerDetailsRQService.PassengerDetail(passengerDetailModel);
                //string a = vNAWSPassengerDetailsRQService.PassengerDetail(passengerDetailModel);
                // end  transaction
                VNATransaction vNATransaction = new VNATransaction();
                //vNATransaction.EndTransaction(tokenModel);
                var End = vNATransaction.EndTransaction(_session);
                End = vNATransaction.EndTransaction(_session);
                //  retur value
                return(Notifization.Data("OK", passengerDetailsRS));
                //}
            }
            catch (Exception ex)
            {
                return(Notifization.TEST("OK" + ex));
            }
        }
 public AIRService.WebService.WSOTA_AirPriceLLSRQ.OTA_AirPriceRS AirPrice(AirPriceModel model)
 {
     try
     {
         WebService.WSOTA_AirPriceLLSRQ.MessageHeader messageHeader = new WebService.WSOTA_AirPriceLLSRQ.MessageHeader
         {
             MessageData = new WebService.WSOTA_AirPriceLLSRQ.MessageData()
         };
         messageHeader.MessageData.Timestamp = DateTime.Now.ToString("s").Replace("-", "").Replace(":", "") + "Z";
         messageHeader.ConversationId        = model.ConversationID;
         messageHeader.Service = new WebService.WSOTA_AirPriceLLSRQ.Service();
         messageHeader.Action  = "OTA_AirPriceLLSRQ";
         messageHeader.From    = new WebService.WSOTA_AirPriceLLSRQ.From
         {
             PartyId = new WebService.WSOTA_AirPriceLLSRQ.PartyId[1]
         };
         var partyID = new WebService.WSOTA_AirPriceLLSRQ.PartyId
         {
             Value = "WebServiceClient"
         };
         messageHeader.From.PartyId[0] = partyID;
         //
         messageHeader.To = new WebService.WSOTA_AirPriceLLSRQ.To
         {
             PartyId = new WebService.WSOTA_AirPriceLLSRQ.PartyId[1]
         };
         partyID = new WebService.WSOTA_AirPriceLLSRQ.PartyId
         {
             Value = "WebServiceSupplier"
         };
         messageHeader.To.PartyId[0] = partyID;
         //
         WebService.WSOTA_AirPriceLLSRQ.Security1 security = new WebService.WSOTA_AirPriceLLSRQ.Security1
         {
             BinarySecurityToken = model.Token
         };
         var listCustomer = new List <WebService.WSOTA_AirPriceLLSRQ.OTA_AirPriceRQPriceRequestInformationOptionalQualifiersPricingQualifiersPassengerType>();
         if (model.ADT > 0)
         {
             var data = new WebService.WSOTA_AirPriceLLSRQ.OTA_AirPriceRQPriceRequestInformationOptionalQualifiersPricingQualifiersPassengerType
             {
                 Code     = "ADT",
                 Quantity = model.ADT.ToString()
             };
             listCustomer.Add(data);
         }
         if (model.CNN > 0)
         {
             var data = new WebService.WSOTA_AirPriceLLSRQ.OTA_AirPriceRQPriceRequestInformationOptionalQualifiersPricingQualifiersPassengerType
             {
                 Code     = "CNN",
                 Quantity = model.CNN.ToString()
             };
             listCustomer.Add(data);
         }
         if (model.INF > 0)
         {
             var data = new WebService.WSOTA_AirPriceLLSRQ.OTA_AirPriceRQPriceRequestInformationOptionalQualifiersPricingQualifiersPassengerType
             {
                 Code     = "INF",
                 Quantity = model.INF.ToString()
             };
             listCustomer.Add(data);
         }
         //
         WebService.WSOTA_AirPriceLLSRQ.OTA_AirPriceRQ oTA_AirPriceRQ = new WebService.WSOTA_AirPriceLLSRQ.OTA_AirPriceRQ
         {
             PriceRequestInformation = new WebService.WSOTA_AirPriceLLSRQ.OTA_AirPriceRQPriceRequestInformation()
         };
         oTA_AirPriceRQ.PriceRequestInformation.Retain             = true;
         oTA_AirPriceRQ.PriceRequestInformation.RetainSpecified    = true;
         oTA_AirPriceRQ.PriceRequestInformation.OptionalQualifiers = new WebService.WSOTA_AirPriceLLSRQ.OTA_AirPriceRQPriceRequestInformationOptionalQualifiers
         {
             PricingQualifiers = new WebService.WSOTA_AirPriceLLSRQ.OTA_AirPriceRQPriceRequestInformationOptionalQualifiersPricingQualifiers()
         };
         oTA_AirPriceRQ.PriceRequestInformation.OptionalQualifiers.PricingQualifiers.PassengerType = listCustomer.ToArray();
         var lSegment = new List <WebService.WSOTA_AirPriceLLSRQ.OTA_AirPriceRQFlightSegment>();
         var rph      = 0;
         foreach (var item in model.lFlight)
         {
             rph++;
             var Segment = new WebService.WSOTA_AirPriceLLSRQ.OTA_AirPriceRQFlightSegment
             {
                 ArrivalDateTime   = item.ArrivalDateTime.ToString("yyyy-MM-dd'T'HH:mm"),
                 DepartureDateTime = item.DepartureDateTime.ToString("yyyy-MM-dd'T'HH:mm"),
                 FlightNumber      = item.FlightNumber,
                 ResBookDesigCode  = item.ResBookDesigCode,
                 RPH = rph.ToString(),
                 DestinationLocation = new WebService.WSOTA_AirPriceLLSRQ.OTA_AirPriceRQFlightSegmentDestinationLocation()
                 {
                     LocationCode = item.DestinationLocation
                 },
                 OriginLocation = new WebService.WSOTA_AirPriceLLSRQ.OTA_AirPriceRQFlightSegmentOriginLocation()
                 {
                     LocationCode = item.OriginLocation
                 },
                 MarketingCarrier = new WebService.WSOTA_AirPriceLLSRQ.OTA_AirPriceRQFlightSegmentMarketingCarrier()
                 {
                     Code         = "VN",
                     FlightNumber = item.FlightNumber
                 },
                 ConnectionInd = "O"
             };
             lSegment.Add(Segment);
         }
         oTA_AirPriceRQ.ReturnHostCommand            = true;
         oTA_AirPriceRQ.ReturnHostCommandSpecified   = true;
         oTA_AirPriceRQ.OriginDestinationInformation = lSegment.ToArray();
         oTA_AirPriceRQ.TimeStamp          = DateTime.Now;
         oTA_AirPriceRQ.TimeStampSpecified = true;
         WebService.WSOTA_AirPriceLLSRQ.OTA_AirPricePortTypeClient client = new WebService.WSOTA_AirPriceLLSRQ.OTA_AirPricePortTypeClient();
         var result = client.OTA_AirPriceRQ(ref messageHeader, ref security, oTA_AirPriceRQ);
         return(result);
     }
     catch (Exception)
     {
         return(null);
     }
 }