1
+ using System . Net ;
2
+ using System . Threading . Tasks ;
1
3
using JsonApiDotNetCore . Configuration ;
2
4
using JsonApiDotNetCore . Controllers ;
3
5
using JsonApiDotNetCore . Models ;
6
+ using JsonApiDotNetCore . Models . JsonApiDocuments ;
4
7
using JsonApiDotNetCore . Services ;
5
8
using JsonApiDotNetCoreExample . Models ;
6
9
using Microsoft . AspNetCore . Mvc ;
9
12
namespace JsonApiDotNetCoreExample . Controllers
10
13
{
11
14
public abstract class AbstractTodoItemsController < T >
12
- : JsonApiController < T > where T : class , IIdentifiable < int >
15
+ : BaseJsonApiController < T > where T : class , IIdentifiable < int >
13
16
{
14
17
protected AbstractTodoItemsController (
15
18
IJsonApiOptions jsonApiOptions ,
@@ -19,6 +22,7 @@ protected AbstractTodoItemsController(
19
22
{ }
20
23
}
21
24
25
+ [ DisableRoutingConvention ]
22
26
[ Route ( "/abstract" ) ]
23
27
public class TodoItemsTestController : AbstractTodoItemsController < TodoItem >
24
28
{
@@ -28,5 +32,49 @@ public TodoItemsTestController(
28
32
IResourceService < TodoItem > service )
29
33
: base ( jsonApiOptions , loggerFactory , service )
30
34
{ }
35
+
36
+ [ HttpGet ]
37
+ public override async Task < IActionResult > GetAsync ( ) => await base . GetAsync ( ) ;
38
+
39
+ [ HttpGet ( "{id}" ) ]
40
+ public override async Task < IActionResult > GetAsync ( int id ) => await base . GetAsync ( id ) ;
41
+
42
+ [ HttpGet ( "{id}/relationships/{relationshipName}" ) ]
43
+ public override async Task < IActionResult > GetRelationshipsAsync ( int id , string relationshipName )
44
+ => await base . GetRelationshipsAsync ( id , relationshipName ) ;
45
+
46
+ [ HttpGet ( "{id}/{relationshipName}" ) ]
47
+ public override async Task < IActionResult > GetRelationshipAsync ( int id , string relationshipName )
48
+ => await base . GetRelationshipAsync ( id , relationshipName ) ;
49
+
50
+ [ HttpPost ]
51
+ public override async Task < IActionResult > PostAsync ( TodoItem entity )
52
+ {
53
+ await Task . Yield ( ) ;
54
+
55
+ return NotFound ( new Error ( HttpStatusCode . NotFound )
56
+ {
57
+ Title = "NotFound ActionResult with explicit error object."
58
+ } ) ;
59
+ }
60
+
61
+ [ HttpPatch ( "{id}" ) ]
62
+ public override async Task < IActionResult > PatchAsync ( int id , [ FromBody ] TodoItem entity )
63
+ {
64
+ return await base . PatchAsync ( id , entity ) ;
65
+ }
66
+
67
+ [ HttpPatch ( "{id}/relationships/{relationshipName}" ) ]
68
+ public override async Task < IActionResult > PatchRelationshipsAsync (
69
+ int id , string relationshipName , [ FromBody ] object relationships )
70
+ => await base . PatchRelationshipsAsync ( id , relationshipName , relationships ) ;
71
+
72
+ [ HttpDelete ( "{id}" ) ]
73
+ public override async Task < IActionResult > DeleteAsync ( int id )
74
+ {
75
+ await Task . Yield ( ) ;
76
+
77
+ return NotFound ( ) ;
78
+ }
31
79
}
32
80
}
0 commit comments