Skip to content

Commit

Permalink
add query filer parameters to rest api datasource
Browse files Browse the repository at this point in the history
  • Loading branch information
sachatrauwaen committed Nov 16, 2021
1 parent 06fa5eb commit b796c0a
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 1 deletion.
1 change: 1 addition & 0 deletions OpenContent/Components/Datasource/DefaultDataItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ namespace Satrabel.OpenContent.Components.Datasource
{
public class DefaultDataItem : IDataItem
{
[Obsolete("Please use constructor with parameters 12/10/2021")]
public DefaultDataItem()
{
}
Expand Down
27 changes: 27 additions & 0 deletions OpenContent/Components/Datasource/RestApiDataSource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,33 @@ public override IDataItems GetAll(DataSourceContext context, Select selectQuery)
}
}

foreach (var f in selectQuery.Query.FilterRules)
{
if (f.Value != null)
{
if (!query.Contains('?'))
query += "?";
else
query += "&";

query += f.Field + "=" + f.Value.AsString;
}
else if (f.MultiValue != null)

{
foreach (var val in f.MultiValue)
{
if (!query.Contains('?'))
query += "?";
else
query += "&";

query += f.Field + "=" + val.AsString;
}

}
}

if (!query.Contains('?'))
query += "?";
else
Expand Down
2 changes: 1 addition & 1 deletion OpenContent/OpenContent.dnn
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@
<name>Handlebars.dll</name>
<path>bin</path>
</assembly>
<assembly>
<assembly>
<name>EPPlus.dll</name>
<path>bin</path>
</assembly>
Expand Down

0 comments on commit b796c0a

Please sign in to comment.