예제 #1
0
        private async Task <bool> GetDataFromMystifly(List <Domain.BookFlightResponse> list, BookFlightModel model)
        {
            var supplierAgencyDetails = supplierAgencyServices.GetSupplierRouteBySupplierCodeAndAgencyCode(model.BookFlightEntity.BookFlight.AgencyCode
                                                                                                           , model.BookFlightEntity.BookFlight.SupplierCode, "book/flights");

            //codt to add booking details in DB
            BookingData _BookingData = new BookingData();

            _BookingData = await supplierAgencyServices.BookFlights(model.BookFlightEntity.BookFlight.Email, supplierAgencyDetails.AgencyID, model.BookFlightEntity.BookFlight.PhoneNumber,
                                                                    model.BookFlightEntity.BookFlight.Faresourcecode, supplierAgencyDetails.SupplierId);

            //code to add air passengetdetails in to DB
            await supplierAgencyServices.AddAirPassengers(model.BookFlightEntity.BookFlight.TravelerInfo, _BookingData.BookingRefID.ToString(), model.BookFlightEntity.BookFlight.CustomerInfo.Email, model.BookFlightEntity.BookFlight.CustomerInfo.PhoneNumber, model.BookFlightEntity.BookFlight.CustomerInfo.PhoneCountry, _BookingData.userID.ToString());

            // await supplierAgencyServices.AddAirbookingCost(model.BookFlight.TravelerInfo, bookingID);
            //Add data to tblairbookingcost start
            var BookingCostID = await supplierAgencyServices.InsertIntotblairbookingcost(_BookingData.BookingRefID.ToString(), Convert.ToDouble(model.Totalfaregroup.TotalBaseNet),
                                                                                         Convert.ToDouble(model.Totalfaregroup.TotalTaxNet), Convert.ToDouble(model.Totalfaregroup.PaidAmount), model.Totalfaregroup.NetCurrency,
                                                                                         Convert.ToInt16(model.Totalfaregroup.MarkupTypeID), Convert.ToDouble(model.Totalfaregroup.MarkupValue), model.Totalfaregroup.MarkupCurrency,
                                                                                         Convert.ToDouble(model.Totalfaregroup.SellAmount), model.Totalfaregroup.SellCurrency,
                                                                                         Convert.ToDouble(model.Totalfaregroup.AdditionalServiceFee), Convert.ToDouble(model.Totalfaregroup.CancellationAmount), model.Totalfaregroup.CancellationCurrency);

            //Add data to tblairbookingcost end
            //Add to AirBookingCostBreakup start

            await supplierAgencyServices.InsertIntotblAirBookingCostBreakup(BookingCostID.ToString(), model.CostBreakuppax);

            //Add to AirBookingCostBreakup end
            //Add to PaymentDetails start
            await supplierAgencyServices.InsertIntotblPayment(_BookingData.BookingRefID.ToString(), Convert.ToDouble(model.Totalfaregroup.PaidAmount), model.Totalfaregroup.SellCurrency, model.Totalfaregroup.PaidDate, Convert.ToInt16(model.Totalfaregroup.PaymentTypeID));

            //Add to PaymentDetails End
            //Add to AirOrigingDestination start
            await supplierAgencyServices.InsertIntotblAirOriginDestinationOptions(_BookingData.BookingRefID.ToString(), model.BookFlightEntity.BookFlight.FLLegGroup);

            //Add to AirOrigingDestination End
            //Add to AirbaggageDetails start
            await supplierAgencyServices.InsertIntotblAirbaggageDetails(_BookingData.BookingRefID.ToString(), model.AirBagDetails);

            //Add to AirbaggageDetails End
            //Add to farerules start
            await supplierAgencyServices.InsertIntotblAirFarerules(_BookingData.BookingRefID.ToString(), model.Fareruleseg);

            //Add to farerules End
            //code to add supplier details in to request
            var allSupplierBasicDetails = await supplierAgencyServices.GetSupplierAgencyBasicDetailswithsuppliercode(model.BookFlightEntity.BookFlight.AgencyCode, "T", model.BookFlightEntity.BookFlight.SupplierCode);

            model.BookFlightEntity.BookFlight.SupplierAgencyDetails = allSupplierBasicDetails;

            model.BookFlightEntity.BookFlight.SupplierCode = "";
            model.BookFlightEntity.BookFlight.BookingId    = _BookingData.BookingRefID.ToString();

            string modelStr = JsonConvert.SerializeObject(model.BookFlightEntity);

            var result = await partnerClient.GetBookflight(supplierAgencyDetails.BaseUrl, supplierAgencyDetails.RequestUrl, model.BookFlightEntity);

            string strData = JsonConvert.SerializeObject(result.Data);

            Domain.BookFlightResponse partnerResponseEntity = JsonConvert.DeserializeObject <Domain.BookFlightResponse>(strData);
            if (partnerResponseEntity != null)
            {
                string airlinePNR = partnerResponseEntity.BookFlightResult.Airlinepnr;
                string uniqueID   = partnerResponseEntity.BookFlightResult.UniqueID;
                if ((airlinePNR != "NIL" || uniqueID != "NIL") && (airlinePNR != "NA" || uniqueID != "NA"))
                {
                    //Update tblbooking (UniqId,Pnr no)
                    await supplierAgencyServices.InsertIntotblBookingData(_BookingData.BookingRefID.ToString(), airlinePNR, uniqueID);

                    await supplierAgencyServices.UpdateTblBooking(_BookingData.BookingRefID.ToString(), partnerResponseEntity.BookFlightResult.Airlinepnr);

                    await supplierAgencyServices.UpdateTblAirpassemgers(_BookingData.BookingRefID.ToString(), partnerResponseEntity.BookFlightResult.Airlinepnr);

                    await supplierAgencyServices.InsertIntotblBookingHistory(_BookingData.BookingRefID.ToString(), _BookingData.userID.ToString(), "HK");

                    //Update tblairpassengerdetails (Pnr no)
                }
                list.Add(partnerResponseEntity);
                return(true);
            }
            return(false);
        }