-
-
Notifications
You must be signed in to change notification settings - Fork 157
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #83 from Research-Institute/develop
v1.3.0
- Loading branch information
Showing
20 changed files
with
516 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
using System; | ||
using System.Linq; | ||
using JsonApiDotNetCore.Models; | ||
using JsonApiDotNetCore.Services; | ||
|
||
namespace JsonApiDotNetCore.Internal.Query | ||
{ | ||
public class AttrFilterQuery | ||
{ | ||
private readonly IJsonApiContext _jsonApiContext; | ||
|
||
public AttrFilterQuery( | ||
IJsonApiContext jsonApiCopntext, | ||
FilterQuery filterQuery) | ||
{ | ||
_jsonApiContext = jsonApiCopntext; | ||
|
||
var attribute = GetAttribute(filterQuery.Key); | ||
|
||
if (attribute == null) | ||
throw new JsonApiException("400", $"{filterQuery.Key} is not a valid property."); | ||
|
||
FilteredAttribute = attribute; | ||
PropertyValue = filterQuery.Value; | ||
FilterOperation = GetFilterOperation(filterQuery.Operation); | ||
} | ||
|
||
public AttrAttribute FilteredAttribute { get; set; } | ||
public string PropertyValue { get; set; } | ||
public FilterOperations FilterOperation { get; set; } | ||
|
||
private FilterOperations GetFilterOperation(string prefix) | ||
{ | ||
if (prefix.Length == 0) return FilterOperations.eq; | ||
|
||
FilterOperations opertion; | ||
if (!Enum.TryParse<FilterOperations>(prefix, out opertion)) | ||
throw new JsonApiException("400", $"Invalid filter prefix '{prefix}'"); | ||
|
||
return opertion; | ||
} | ||
|
||
private AttrAttribute GetAttribute(string propertyName) | ||
{ | ||
return _jsonApiContext.RequestEntity.Attributes | ||
.FirstOrDefault(attr => | ||
attr.InternalAttributeName.ToLower() == propertyName.ToLower() | ||
); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,16 @@ | ||
using JsonApiDotNetCore.Models; | ||
|
||
namespace JsonApiDotNetCore.Internal.Query | ||
{ | ||
public class FilterQuery | ||
{ | ||
public FilterQuery(AttrAttribute filteredAttribute, string propertyValue, FilterOperations filterOperation) | ||
public FilterQuery(string key, string value, string operation) | ||
{ | ||
FilteredAttribute = filteredAttribute; | ||
PropertyValue = propertyValue; | ||
FilterOperation = filterOperation; | ||
Key = key; | ||
Value = value; | ||
Operation = operation; | ||
} | ||
|
||
public AttrAttribute FilteredAttribute { get; set; } | ||
public string PropertyValue { get; set; } | ||
public FilterOperations FilterOperation { get; set; } | ||
public string Key { get; set; } | ||
public string Value { get; set; } | ||
public string Operation { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,17 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<VersionPrefix>1.2.2</VersionPrefix> | ||
<VersionPrefix>1.3.0</VersionPrefix> | ||
<TargetFramework>netcoreapp1.0</TargetFramework> | ||
<AssemblyName>JsonApiDotNetCore</AssemblyName> | ||
<PackageId>JsonApiDotNetCore</PackageId> | ||
<RuntimeFrameworkVersion>1.1.1</RuntimeFrameworkVersion> | ||
<PackageTargetFallback>$(PackageTargetFallback);dnxcore50;portable-net45+win8</PackageTargetFallback> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.AspNetCore.Routing" Version="1.1.1" /> | ||
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="1.1.2" /> | ||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="1.1.1" /> | ||
<PackageReference Include="Microsoft.Extensions.Logging" Version="1.1.1" /> | ||
<PackageReference Include="System.ValueTuple" Version="4.3.0" /> | ||
</ItemGroup> | ||
|
||
</Project> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
100 changes: 100 additions & 0 deletions
100
src/JsonApiDotNetCoreExample/Migrations/20170330020650_AddAssignedTodoItems.Designer.cs
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.