Пример #1
0
        private async Task <bool> GetDataFromMystifly(List <Domain.BookFlightResponse> list, Models.BookFlightModel model)
        {
            try
            {
                var supplierAgencyDetails = supplierAgencyServices.GetSupplierRouteBySupplierCodeAndAgencyCode(model.BookFlightEntity.BookFlight.AgencyCode

                                                                                                               , model.BookFlightEntity.BookFlight.SupplierCode, "book/flights");
                List <SupplierAgencyDetails> _supplierAgencyDetailslist = new List <SupplierAgencyDetails> {
                    supplierAgencyDetails
                };
                model.BookFlightEntity.BookFlight.SupplierAgencyDetails = _supplierAgencyDetailslist;
                Paymentinfo paymentinfo = bookingServices.GetPaymentCardDetails(model.BookFlightEntity.BookFlight.AgencyCode);
                model.BookFlightEntity.BookFlight.PaymentInfo = paymentinfo;


                BookingData _BookingData = new BookingData();
                BusinessEntitties.BookFlightModel bookFlightModel = new BusinessEntitties.BookFlightModel();
                bookFlightModel.AirBagDetails  = model.AirBagDetails;
                bookFlightModel.CostBreakuppax = model.CostBreakuppax;
                bookFlightModel.Fareruleseg    = model.Fareruleseg;
                bookFlightModel.Totalfaregroup = model.Totalfaregroup;
                bookFlightModel.BookFlightEntity.BookFlight = model.BookFlightEntity.BookFlight;
                bookFlightModel.costAirMarkUp = model.costAirMarkUp;

                //Check RefID Exist in Database
                bool Exist = false;
                if (model.BookFlightEntity.BookFlight.BookingId != "")
                {
                    Exist = bookingServices.CheckBookingRefIDExist(long.Parse(model.BookFlightEntity.BookFlight.BookingId));
                }
                if (Exist)
                {
                    //Update DataBase With New Price Details and Change Password
                    await bookingServices.UpdateAllDetailsWithRefID(bookFlightModel);
                }
                else
                {
                    // Add New Record in Database
                    _BookingData = await bookingServices.SavingAirBookingFlight(bookFlightModel, supplierAgencyDetails.AgencyID, supplierAgencyDetails.SupplierId);
                }

                //Send Booking Request To Supplier
                string modelStr = JsonConvert.SerializeObject(model.BookFlightEntity);
                var    result   = await partnerClient.GetBookflight(supplierAgencyDetails.BaseUrl, supplierAgencyDetails.RequestUrl, model.BookFlightEntity);

                string responseStr = JsonConvert.SerializeObject(result.Data);
                string jsonData    = JsonConvert.SerializeObject(result.Data);
                string requestStr  = JsonConvert.SerializeObject(model);
                string agencyCode  = model.BookFlightEntity.BookFlight.AgencyCode;
                await supplierAgencyServices.SaveLog("book-Flight", agencyCode, requestStr, jsonData);

                if (jsonData != "null")
                {
                    Domain.BookFlightResponse partnerResponseEntity = JsonConvert.DeserializeObject <Domain.BookFlightResponse>(responseStr);
                    string bookStatus = partnerResponseEntity.BookFlightResult.Status;
                    if (bookStatus == "PRICECHANGED")
                    {
                        //Send Status to website with new bookingRefID
                        partnerResponseEntity.BookFlightResult.BookingId = _BookingData.BookingRefID.ToString();
                        list.Add(partnerResponseEntity);
                        return(true);
                    }
                    else
                    {
                        //Check PNR is Successfully Generated
                        bool pnrstatus = CheckPNRorUniqIDexistornot(partnerResponseEntity);
                        if (pnrstatus)
                        {
                            //Update PNR,BookingStatus and UniqID
                            //Add Errors To Database
                            bookingServices.UpdatePNRandStatus(partnerResponseEntity, _BookingData, bookFlightModel, supplierAgencyDetails.SupplierCode);
                            partnerResponseEntity.BookFlightResult.BookingId = _BookingData.BookingRefID.ToString();
                            list.Add(partnerResponseEntity);
                        }
                        else
                        {
                            list.Add(partnerResponseEntity);
                        }
                    }
                }
                else
                {
                    //Send Error Message to website
                    // Error message = Supplier Note Responding
                    Domain.BookFlightResponse bookFlightResponse = GetErrorTag("0000", "Supplier not responding");
                    list.Add(bookFlightResponse);
                }
                return(true);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Пример #2
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);
        }