コード例 #1
0
ファイル: GetTripDetails.cs プロジェクト: fardeencs/WebApi2
        private async Task <GetTripDetailsModelRS> GetTraveldetails(List <Domain.GetTripDetailsModelRS> list, Models.GetTripDetailsModel model)
        {
            GetTripDetailsModelRS    _GetTripDetailsModelRS   = new GetTripDetailsModelRS();
            SupplierTripDetailsModel supplierTripDetailsModel = new SupplierTripDetailsModel();

            if (model.ConnectiontoDBreq.Issupplier == true)
            {
                var bookedSupplierInfo = bookingServices.GetBookedSupplierInfo(long.Parse(model.ConnectiontoDBreq.BookingRefID));
                if (bookedSupplierInfo != null)
                {
                    model.ConnectiontoDBreq.SupplierCodeDb   = bookedSupplierInfo.SupplierCodeDb;
                    model.ConnectiontoDBreq.SupplierPnr      = bookedSupplierInfo.SupplierPnr;
                    model.ConnectiontoDBreq.SupplierUniqueId = bookedSupplierInfo.SupplierUniqueId;
                }
                if (bookedSupplierInfo.BookingStatusCode == "HK" || bookedSupplierInfo.BookingStatusCode == "TP")
                {
                    var supplierAgencyDetails = supplierAgencyServices.GetSupplierRouteBySupplierCodeAndAgencyCode(model.ConnectiontoDBreq.AgencyCodeDb, model.ConnectiontoDBreq.SupplierCodeDb, "getDBtripdetails");
                    if (supplierAgencyDetails != null)
                    {
                        List <SupplierAgencyDetails> SupplierAgencyDetailsList = new List <SupplierAgencyDetails>()
                        {
                            supplierAgencyDetails
                        };
                        supplierTripDetailsModel = new SupplierTripDetailsModel()
                        {
                            AgencyCode            = model.ConnectiontoDBreq.AgencyCodeDb,
                            SupplierCode          = model.ConnectiontoDBreq.SupplierCodeDb,
                            Target                = model.ConnectiontoDBreq.Target,
                            UniqueID              = model.ConnectiontoDBreq.SupplierUniqueId,
                            supplierAgencyDetails = SupplierAgencyDetailsList
                        };
                        string req    = JsonConvert.SerializeObject(supplierTripDetailsModel);
                        var    result = await partnerClient.GetSupplierTripDetails(supplierAgencyDetails.BaseUrl, supplierAgencyDetails.RequestUrl, supplierTripDetailsModel);

                        string requestStr  = JsonConvert.SerializeObject(model);
                        string resposneStr = JsonConvert.SerializeObject(result);
                        string agencyCode  = model.ConnectiontoDBreq.AgencyCodeDb;
                        await supplierAgencyServices.SaveLog("supplier-trip-details", agencyCode, requestStr, resposneStr);

                        if (result != null)
                        {
                            string strData = JsonConvert.SerializeObject(result);
                            Domain.SupplierTripDetailsResponse supplierTripDetailsResponse = new Domain.SupplierTripDetailsResponse();
                            try
                            {
                                supplierTripDetailsResponse = JsonConvert.DeserializeObject <Domain.SupplierTripDetailsResponse>(strData);
                                if (supplierTripDetailsResponse.data.success == true)
                                {
                                    bookingServices.UpdateBookingInformatiomFromTripDetails(supplierTripDetailsResponse, long.Parse(model.ConnectiontoDBreq.BookingRefID));
                                }
                            }
                            catch (Exception ex)
                            {
                                throw ex;
                            }
                        }
                    }
                }
            }
            _GetTripDetailsModelRS = await supplierAgencyServices.GetTravellerDetailsfromDB(model.ConnectiontoDBreq.BookingRefID.ToString());

            return(_GetTripDetailsModelRS);
        }