1+ using System . Net ;
2+ using System . Threading . Tasks ;
13using JsonApiDotNetCore . Configuration ;
24using JsonApiDotNetCore . Controllers ;
35using JsonApiDotNetCore . Models ;
6+ using JsonApiDotNetCore . Models . JsonApiDocuments ;
47using JsonApiDotNetCore . Services ;
58using JsonApiDotNetCoreExample . Models ;
69using Microsoft . AspNetCore . Mvc ;
912namespace JsonApiDotNetCoreExample . Controllers
1013{
1114 public abstract class AbstractTodoItemsController < T >
12- : JsonApiController < T > where T : class , IIdentifiable < int >
15+ : BaseJsonApiController < T > where T : class , IIdentifiable < int >
1316 {
1417 protected AbstractTodoItemsController (
1518 IJsonApiOptions jsonApiOptions ,
@@ -19,6 +22,7 @@ protected AbstractTodoItemsController(
1922 { }
2023 }
2124
25+ [ DisableRoutingConvention ]
2226 [ Route ( "/abstract" ) ]
2327 public class TodoItemsTestController : AbstractTodoItemsController < TodoItem >
2428 {
@@ -28,5 +32,49 @@ public TodoItemsTestController(
2832 IResourceService < TodoItem > service )
2933 : base ( jsonApiOptions , loggerFactory , service )
3034 { }
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+ }
3179 }
3280}
0 commit comments