|
4 | 4 |
|
5 | 5 | namespace JsonApiDotNetCore.Internal.Query |
6 | 6 | { |
7 | | - public class AttrFilterQuery : BaseFilterQuery |
| 7 | + public class AttrFilterQuery : AttrQuery |
8 | 8 | { |
9 | | - private readonly IJsonApiContext _jsonApiContext; |
10 | | - |
11 | 9 | public AttrFilterQuery( |
12 | 10 | IJsonApiContext jsonApiContext, |
13 | 11 | FilterQuery filterQuery) |
| 12 | + :base(jsonApiContext, filterQuery) |
14 | 13 | { |
15 | | - _jsonApiContext = jsonApiContext; |
16 | | - |
17 | | - var attribute = GetAttribute(filterQuery.Attribute); |
18 | | - |
19 | | - if (attribute == null) |
20 | | - throw new JsonApiException(400, $"'{filterQuery.Attribute}' is not a valid attribute."); |
21 | | - |
22 | | - if (attribute.IsFilterable == false) |
23 | | - throw new JsonApiException(400, $"Filter is not allowed for attribute '{attribute.PublicAttributeName}'."); |
| 14 | + if (Attribute.IsFilterable == false) |
| 15 | + throw new JsonApiException(400, $"Filter is not allowed for attribute '{Attribute.PublicAttributeName}'."); |
24 | 16 |
|
25 | | - FilteredAttribute = attribute; |
26 | 17 | PropertyValue = filterQuery.Value; |
27 | | - FilterOperation = GetFilterOperation(filterQuery.Operation); |
| 18 | + FilterOperation = FilterOperations.GetFilterOperation(filterQuery.Operation); |
28 | 19 | } |
29 | 20 |
|
30 | | - public AttrAttribute FilteredAttribute { get; } |
31 | 21 | public string PropertyValue { get; } |
32 | | - public FilterOperations FilterOperation { get; } |
| 22 | + public FilterOperationsEnum FilterOperation { get; } |
33 | 23 |
|
34 | | - private AttrAttribute GetAttribute(string attribute) => |
35 | | - _jsonApiContext.RequestEntity.Attributes.FirstOrDefault(attr => attr.Is(attribute)); |
36 | 24 | } |
37 | 25 | } |
0 commit comments