Exemplo n.º 1
0
        private async Task <bool> CancelbookingfromSupplier(List <CancelPNRResponse> list, Models.CancelBookingModel model)
        {
            var supplierAgencyDetails = supplierAgencyServices.GetSupplierRouteBySupplierCodeAndAgencyCode(model.AgencyCode, model.SupplierCode, "cancel-pnr");

            if (supplierAgencyDetails != null)
            {
                List <SupplierAgencyDetails> SupplierAgencyDetailsList = new List <SupplierAgencyDetails>()
                {
                    supplierAgencyDetails
                };
                model.supplierAgencyDetails = SupplierAgencyDetailsList;
                string req    = JsonConvert.SerializeObject(model);
                var    result = await partnerClient.GetCancelPNRStatus(supplierAgencyDetails.BaseUrl, supplierAgencyDetails.RequestUrl, model);

                string requestStr  = JsonConvert.SerializeObject(model);
                string resposneStr = JsonConvert.SerializeObject(result);
                string agencyCode  = model.AgencyCode;
                await supplierAgencyServices.SaveLog("cancel-Flight", agencyCode, requestStr, resposneStr);

                if (result != null)
                {
                    string strData = JsonConvert.SerializeObject(result.Data);
                    Domain.CancelPNRResponse partnerResponseEntity = null;
                    partnerResponseEntity = JsonConvert.DeserializeObject <Domain.CancelPNRResponse>(strData);
                    partnerResponseEntity.BookingRefID = model.BookingRefID;
                    partnerResponseEntity.UserID       = model.UserID;
                    if (partnerResponseEntity != null)
                    {
                        list.Add(partnerResponseEntity);
                        if (partnerResponseEntity.success == true)
                        {
                            await bookingServices.UpdateBookingStatusafterIssueTicket("XX", model.BookingRefID, model.UserID);
                        }
                        else
                        {
                        }
                        return(true);
                    }
                    else
                    {
                        list.Add(partnerResponseEntity);
                        return(true);
                    }
                }
                else
                {
                    Error[] errors = new Error[1];
                    Error   error  = new Error()
                    {
                        Code    = "",
                        Message = "Supplier not responding"
                    };
                    errors[0] = error;
                    CancelPNRResponse cancelPNRResponse = new CancelPNRResponse()
                    {
                        BookingRefID = model.BookingRefID,
                        success      = false,
                        uniqueID     = model.UniqueId,
                        UserID       = model.UserID,
                        errors       = errors
                    };
                    list.Add(cancelPNRResponse);
                    return(true);
                }
            }
            else
            {
                return(false);
            }
        }