private Domain.Rootobject FilteredData(List <Domain.Rootobject> allsupplierData) { var allsupplieFlightIndexData = allsupplierData.SelectMany(x => x.fareMasterPricerTravelBoardSearchReply.flightIndex).ToList(); Faremasterpricertravelboardsearchreply fistRooTObject = allsupplierData.First().fareMasterPricerTravelBoardSearchReply; Domain.Rootobject rootObject = new Domain.Rootobject(); Faremasterpricertravelboardsearchreply faremasterpricertravelboardsearchreply = GetCommonRootObject(fistRooTObject); List <Flightindex> flightindexList = new List <Flightindex>(); /*during debugg uncomment this code and varify your correct data*/ //JavaScriptSerializer serializer = new JavaScriptSerializer(); //string jsonString = serializer.Serialize(allsupplieFlightIndexData); var groupedFlightsByKey = allsupplieFlightIndexData .GroupBy(item => item.SegmentRef.key) .ToDictionary(grp => grp.Key, grp => grp.ToList()); foreach (var item in groupedFlightsByKey) { Flightindex flightindex = item.Value.OrderBy(x => x.fare.amount).FirstOrDefault(); flightindexList.Add(flightindex); } faremasterpricertravelboardsearchreply.flightIndex = flightindexList.OrderBy(x => x.fare.amount).ToList(); rootObject.fareMasterPricerTravelBoardSearchReply = faremasterpricertravelboardsearchreply; return(rootObject); }
private async Task <bool> GetDataFromAmadeus(List <Domain.Rootobject> list, Models.Rootobject model, List <SupplierAgencyDetails> allSupplierAgencyDetails, string key) { string strData = string.Empty; AddSupplierDetailsToRequestObject(model, allSupplierAgencyDetails, SupplierCodeAmadeous); string baseUri = ConficBase.GetConfigAppValue(BaseUrlAmadeous); string reqUri = ConficBase.GetConfigAppValue(ReqUrlAmadeous); bool isFetchedFromDb = false; // strData = await GetSupplierResponseFromDb(model, ConficBase.GetConfigAppValue(SupplierCodeAmadeous), key); if (string.IsNullOrEmpty(strData)) { var result = await partnerClient.GetPartnerData(baseUri, reqUri, model); strData = JsonConvert.SerializeObject(result.Data); isFetchedFromDb = true; } Domain.Rootobject partnerResponseEntity = JsonConvert.DeserializeObject <Domain.Rootobject>(strData); if (partnerResponseEntity != null) { if (partnerResponseEntity.fareMasterPricerTravelBoardSearchReply.flightIndex != null && partnerResponseEntity.fareMasterPricerTravelBoardSearchReply.flightIndex.ToList().Count() > 0) { list.Add(partnerResponseEntity); if (isFetchedFromDb) { AddSearchDetails(model, strData, ConficBase.GetConfigAppValue(SupplierCodeAmadeous), key); } //CreateJSONDoc(strData, model.CommonRequestSearch.AgencyCode, ConficBase.GetConfigAppValue(SupplierCodeAmadeous), key); return(true); } } return(false); }
private async Task <Domain.Rootobject> GetDataFromPartnerThree(List <Domain.Rootobject> list) { string baseUri = "http://localhost:18293/"; string reqUri = "partnerthree/amadeus"; var result = await partnerClient.GetPartnerData(baseUri, reqUri); string strData = JsonConvert.SerializeObject(result.Data); Domain.Rootobject partnerResponseEntity = JsonConvert.DeserializeObject <Domain.Rootobject>(strData); list.Add(partnerResponseEntity); return(partnerResponseEntity); }
private async Task <Domain.Rootobject> GetDataFromPartnerOne(List <Domain.Rootobject> list) { string baseUri = "http://localhost:18313/"; //string reqUri = "partnerone/all/async"; string reqUri = "mystifly-partner/rootobject"; var result = await partnerClient.GetPartnerData(baseUri, reqUri); string strData = JsonConvert.SerializeObject(result.Data); Domain.Rootobject partnerResponseEntity = JsonConvert.DeserializeObject <Domain.Rootobject>(strData); list.Add(partnerResponseEntity); return(partnerResponseEntity); }
public async Task <ResponseObject> Handle(Models.Rootobject message) { var allSupplierBasicDetails = await supplierAgencyServices.GetSupplierAgencyBasicDetails(message.CommonRequestSearch.AgencyCode, "T"); //if (allSupplierBasicDetails != null && allSupplierBasicDetails.Count() > 0) //{ // message.SupplierAgencyDetails = allSupplierBasicDetails; // //JavaScriptSerializer serializer = new JavaScriptSerializer(); // //string jsonString = serializer.Serialize(message); //} string key = GenrateSavedResponseKey(message); List <Domain.Rootobject> allsupplierData = new List <Domain.Rootobject>(); CreateResponseTime("Mystifly"); // bool mystiflyResponse = await GetDataFromMystifly(allsupplierData, message, allSupplierBasicDetails, key); Task <bool> mystiflyResponse = GetDataFromMystifly(allsupplierData, message, allSupplierBasicDetails, key); //var pythonWatch = System.Diagnostics.Stopwatch.StartNew(); CreateResponseTime("Python"); //bool pythonResponse = await GetDataFromPython(allsupplierData, message, allSupplierBasicDetails, key); Task <bool> pythonResponse = GetDataFromPython(allsupplierData, message, allSupplierBasicDetails, key); CreateResponseTime("Amedious"); // bool amadiousResponse = await GetDataFromAmadeus(allsupplierData, message, allSupplierBasicDetails, key); Task <bool> amadiousResponse = GetDataFromAmadeus(allsupplierData, message, allSupplierBasicDetails, key); //await Task.Delay(15000); await mystiflyResponse; await pythonResponse; await amadiousResponse; if (allsupplierData == null || allsupplierData.Count() <= 0) { return(null); } Domain.Rootobject filteredData = FilteredData(allsupplierData); var response = new ResponseObject { ResponseMessage = new HttpResponseMessage(HttpStatusCode.OK), Data = filteredData, Message = "Data retrieved Successfully", IsSuccessful = true }; return(response); }
public async Task <ResponseObject> Handle(Models.Rootobject message) { string key = GenrateSavedResponseKey(message); List <Domain.Rootobject> allsupplierData = new List <Domain.Rootobject>(); if (SupplierCode.MIS001.ToString().ToUpper() == message.CommonRequestSearch.SupplierCode.Trim().ToUpper()) { bool mystiflyResponse = await GetDataFromMystifly(allsupplierData, message, key); } else if (SupplierCode.PYT001.ToString().ToUpper() == message.CommonRequestSearch.SupplierCode.Trim().ToUpper()) { bool pythonResponse = await GetDataFromPython(allsupplierData, message, key); } else if (SupplierCode.AMA001.ToString().ToUpper() == message.CommonRequestSearch.SupplierCode.Trim().ToUpper()) { bool amadiousResponse = await GetDataFromAmadeus(allsupplierData, message, key); } else { #region sync reequest //bool pythonResponse = await GetDataFromPython(allsupplierData, message, key); //bool mystiflyResponse = await GetDataFromMystifly(allsupplierData, message, key); //bool amadiousResponse = await GetDataFromAmadeus(allsupplierData, message, key); #endregion #region -- async req-- //CreateResponseTime("Amedious"); Task <bool> amadiousResponse = GetDataFromAmadeus(allsupplierData, message, key); //CreateResponseTime("Python"); Task <bool> pythonResponse = GetDataFromPython(allsupplierData, message, key); //CreateResponseTime("Mystifly"); Task <bool> mystiflyResponse = GetDataFromMystifly(allsupplierData, message, key); await amadiousResponse; await pythonResponse; await mystiflyResponse; //int timeout = 20000; //amadiousResponse.Wait(timeout); //pythonResponse.Wait(timeout); //mystiflyResponse.Wait(timeout); #endregion } if (allsupplierData == null || allsupplierData.Count() <= 0) { return(null); } Domain.Rootobject filteredData = FilteredData(allsupplierData, message.CommonRequestSearch.IsFiltered); //Models.TestData allData = new Models.TestData(); //allData.NonFilteredData = allsupplierData; //allData.FilteredData = filteredData; var response = new ResponseObject { ResponseMessage = new HttpResponseMessage(HttpStatusCode.OK), Data = filteredData, Message = "Data retrieved Successfully", IsSuccessful = true }; return(response); }
private async Task <bool> GetDataFromAmadeus(List <Domain.Rootobject> list, Models.Rootobject model, string key) { string strData = string.Empty; //bool isAdded = await AddSupplierDetailsToRequestObject(model, this._SupplierCodeAmadeous); try { SupplierAgencyDetails supplierDetails = await agenciesBasicDetails.GeBasicDetailsOfSupplier(model.CommonRequestSearch.AgencyCode, SupplierCode.AMA001.ToString(), "T"); if (supplierDetails != null) { supplierDetails.AgencyCode = model.CommonRequestSearch.AgencyCode; List <SupplierAgencyDetails> supplierAgencyDetails = new List <SupplierAgencyDetails>(); supplierAgencyDetails.Add(supplierDetails); // model.SupplierAgencyDetails = supplierAgencyDetails; SearchFlightsAmadeous requestModel = new SearchFlightsAmadeous(); requestModel.cabin = model.cabin; requestModel.CommonRequestSearch = model.CommonRequestSearch; requestModel.Currency = model.Currency; requestModel.IsRefundable = model.IsRefundable; requestModel.Maxstopquantity = model.Maxstopquantity; requestModel.NonStop = model.NonStop; requestModel.OriginDestinationInformation = model.OriginDestinationInformation; requestModel.PassengerTypeQuantity = model.PassengerTypeQuantity; requestModel.PreferenceLevel = model.PreferenceLevel; requestModel.PreferredAirline = model.PreferredAirline; requestModel.PricingSource = model.PricingSource; requestModel.RequestOption = model.RequestOption; requestModel.Target = model.Target; requestModel.Triptype = model.Triptype; requestModel.SupplierAgencyDetails = supplierAgencyDetails; string baseUri = supplierDetails.BaseUrl; string reqUri = ConficBase.GetConfigAppValue(ReqUrlAmadeous); bool isFetchedFromDb = false; strData = await GetSupplierResponseFromDb(model, SupplierCode.AMA001.ToString(), key); if (string.IsNullOrEmpty(strData)) { // string jsonData = JsonConvert.SerializeObject(model); var result = await partnerClient.GetAmadeusData(baseUri, reqUri, requestModel); strData = JsonConvert.SerializeObject(result.Data); isFetchedFromDb = true; } Domain.Rootobject partnerResponseEntity = JsonConvert.DeserializeObject <Domain.Rootobject>(strData); if (partnerResponseEntity != null) { if (partnerResponseEntity.fareMasterPricerTravelBoardSearchReply.flightIndex != null && partnerResponseEntity.fareMasterPricerTravelBoardSearchReply.flightIndex.ToList().Count() > 0) { list.Add(partnerResponseEntity); if (isFetchedFromDb) { AddSearchDetails(model, strData, ConficBase.GetConfigAppValue(SupplierCodeAmadeous), key); } return(true); } } } }catch (Exception ex) { throw ex; } return(false); }