Skip to content

Commit

Permalink
Merge pull request #474 from noi-techpark/main
Browse files Browse the repository at this point in the history
adding hack for bookablefilter
  • Loading branch information
RudiThoeni authored Dec 2, 2024
2 parents bf2a4ef + ab605b3 commit b7a6c18
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 19 deletions.
7 changes: 6 additions & 1 deletion OdhApiCore/Controllers/api/AccommodationApiController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -639,10 +639,15 @@ private Task<IActionResult> GetFiltered(string[] fields, string? language, uint
//Additional Read Filters to Add Check
AdditionalFiltersToAdd.TryGetValue("Read", out var additionalfilter);

//Hack Bookable Filter
bool? customisbookablefilter = bookablefilter;
if (idfilter != null && idfilter.Count() > 0)
customisbookablefilter = false;

AccommodationHelper myhelper = await AccommodationHelper.CreateAsync(
QueryFactory, idfilter: idfilter, locfilter: locfilter, boardfilter: boardfilter, categoryfilter: categoryfilter, typefilter: typefilter,
featurefilter: featurefilter, featureidfilter: featureidfilter, badgefilter: badgefilter, themefilter: themefilter, altitudefilter: altitudefilter, smgtags: smgtagfilter, activefilter: active,
smgactivefilter: smgactive, bookablefilter: bookablefilter, sourcefilter: sourcefilter, lastchange: updatefrom, langfilter: langfilter, publishedonfilter: publishedon, cancellationToken);
smgactivefilter: smgactive, bookablefilter: customisbookablefilter, sourcefilter: sourcefilter, lastchange: updatefrom, langfilter: langfilter, publishedonfilter: publishedon, cancellationToken);

//Fix if idlist from availabilitysearch is added use this instead of idfilter
if (idlist.Count > 0)
Expand Down
43 changes: 25 additions & 18 deletions OdhApiCore/Filters/AvailabilitySearchInterceptorAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,14 @@ public override async Task OnActionExecutionAsync(ActionExecutingContext context

if (actionid == "GetAccommodations")
{
bool? customisbookablefilter = bookablefilter;
if (idfilter != null && idfilter.Count() > 0)
customisbookablefilter = false;

AccommodationHelper myhelper = await AccommodationHelper.CreateAsync(
QueryFactory, idfilter: idfilter, locfilter: locfilter, boardfilter: boardfilter, categoryfilter: categoryfilter, typefilter: typefilter,
featurefilter: featurefilter, featureidfilter: featureidfilter, badgefilter: badgefilter, themefilter: themefilter, altitudefilter: altitudefilter, smgtags: odhtagfilter, activefilter: active,
smgactivefilter: odhactive, bookablefilter: bookablefilter, sourcefilter: sourcefilter, lastchange: updatefrom, langfilter: langfilter, publishedonfilter: publishedon, (CancellationToken?)context.ActionArguments["cancellationToken"] ?? new());
smgactivefilter: odhactive, bookablefilter: customisbookablefilter, sourcefilter: sourcefilter, lastchange: updatefrom, langfilter: langfilter, publishedonfilter: publishedon, (CancellationToken?)context.ActionArguments["cancellationToken"] ?? new());

var geosearchresult = Helper.GeoSearchHelper.GetPGGeoSearchResult(latitude, longitude, radius);

Expand Down Expand Up @@ -162,27 +166,30 @@ public override async Task OnActionExecutionAsync(ActionExecutingContext context

context.HttpContext.Items.Add("accobooklist", booklist);

if (bokfilterlist.Contains("hgv"))
if (booklist.Count > 0)
{
MssResult mssresult = await GetMSSAvailability(
language: language, arrival: arrival, departure: departure, boardfilter: boardfilter,
roominfo: roominfo, bokfilter: bokfilter, detail: Convert.ToInt32(detail), bookableaccoIDs: booklist,
idsofchannel: idsource, requestsource: msssource, msscache: msscache);

if (mssresult != null)
if (bokfilterlist.Contains("hgv"))
{
context.HttpContext.Items.Add("mssavailablity", mssresult);
}
}
if (bokfilterlist.Contains("lts"))
{
MssResult lcsresult = await GetLCSAvailability(
language: language, arrival: arrival, departure: departure, boardfilter: boardfilter,
roominfo: roominfo, bookableaccoIDs: booklist, requestsource: msssource, lcscache: lcscache);
MssResult mssresult = await GetMSSAvailability(
language: language, arrival: arrival, departure: departure, boardfilter: boardfilter,
roominfo: roominfo, bokfilter: bokfilter, detail: Convert.ToInt32(detail), bookableaccoIDs: booklist,
idsofchannel: idsource, requestsource: msssource, msscache: msscache);

if (lcsresult != null)
if (mssresult != null)
{
context.HttpContext.Items.Add("mssavailablity", mssresult);
}
}
if (bokfilterlist.Contains("lts"))
{
context.HttpContext.Items.Add("lcsavailablity", lcsresult);
MssResult lcsresult = await GetLCSAvailability(
language: language, arrival: arrival, departure: departure, boardfilter: boardfilter,
roominfo: roominfo, bookableaccoIDs: booklist, requestsource: msssource, lcscache: lcscache);

if (lcsresult != null)
{
context.HttpContext.Items.Add("lcsavailablity", lcsresult);
}
}
}
}
Expand Down

0 comments on commit b7a6c18

Please sign in to comment.