public async Task <Result <AccommodationDuplicateReportInfo> > Get(int reportId, string languageCode) { var report = await _context.AccommodationDuplicateReports.SingleOrDefaultAsync(r => r.Id == reportId); if (report == default) { return(Result.Failure <AccommodationDuplicateReportInfo>("Could not find a report")); } var accommodations = new List <SupplierData <Accommodation> >(report.Accommodations.Count); foreach (var supplierAccommodationId in report.Accommodations) { var(_, isFailure, accommodationDetails, result) = await _supplierConnectorManager .Get(supplierAccommodationId.Supplier) .GetAccommodation(supplierAccommodationId.Id, languageCode); if (isFailure) { return(Result.Failure <AccommodationDuplicateReportInfo>($"Could not find accommodation: {result.Detail}")); } accommodations.Add(SupplierData.Create(supplierAccommodationId.Supplier, accommodationDetails)); } return(new AccommodationDuplicateReportInfo(report.Id, report.Created, report.ApprovalState, accommodations)); }
public async Task <Result <SupplierData <AccommodationAvailability>, ProblemDetails> > GetProviderAvailability(Guid searchId, Guid resultId, Suppliers supplier, string accommodationId, string availabilityId, AgentContext agent, string languageCode) { return(await ExecuteRequest() .Bind(ConvertCurrencies) .Map(ApplyMarkups) .Map(AddProviderData) .Tap(SaveToCache)); Task SaveToCache(SupplierData <AccommodationAvailability> details) => _roomSelectionStorage.SaveResult(searchId, resultId, details.Data, details.Source); Task <Result <AccommodationAvailability, ProblemDetails> > ExecuteRequest() => _supplierConnectorManager.Get(supplier).GetAvailability(availabilityId, accommodationId, languageCode); Task <Result <AccommodationAvailability, ProblemDetails> > ConvertCurrencies(AccommodationAvailability availabilityDetails) => _priceProcessor.ConvertCurrencies(agent, availabilityDetails, AvailabilityResultsExtensions.ProcessPrices, AvailabilityResultsExtensions.GetCurrency); Task <DataWithMarkup <AccommodationAvailability> > ApplyMarkups(AccommodationAvailability response) => _priceProcessor.ApplyMarkups(agent, response, AvailabilityResultsExtensions.ProcessPrices); SupplierData <AccommodationAvailability> AddProviderData(DataWithMarkup <AccommodationAvailability> availabilityDetails) => SupplierData.Create(supplier, availabilityDetails.Data); }
public Task Set(Guid searchId, Guid resultId, Guid roomContractSetId, DataWithMarkup <RoomContractSetAvailability> availability, Suppliers supplier) { var key = BuildKey(searchId, resultId, roomContractSetId); var dataToSave = SupplierData.Create(supplier, availability); return(_doubleFlow.SetAsync(key, dataToSave, CacheExpirationTime)); }