88
99namespace JsonApiDotNetCore . Controllers
1010{
11- public class BaseJsonApiController < T >
11+ public class BaseJsonApiController < T >
1212 : BaseJsonApiController < T , int >
1313 where T : class , IIdentifiable < int >
1414 {
@@ -47,7 +47,7 @@ public class BaseJsonApiController<T, TId>
4747 private readonly ICreateService < T , TId > _create ;
4848 private readonly IUpdateService < T , TId > _update ;
4949 private readonly IUpdateRelationshipService < T , TId > _updateRelationships ;
50- private readonly IDeleteService < T , TId > _delete ;
50+ private readonly IDeleteService < T , TId > _delete ;
5151 private readonly IJsonApiContext _jsonApiContext ;
5252
5353 public BaseJsonApiController (
@@ -156,7 +156,7 @@ public virtual async Task<IActionResult> PostAsync([FromBody] T entity)
156156 return Forbidden ( ) ;
157157
158158 if ( _jsonApiContext . Options . ValidateModelState && ! ModelState . IsValid )
159- return BadRequest ( ModelState . ConvertToErrorCollection ( ) ) ;
159+ return BadRequest ( ModelState . ConvertToErrorCollection ( _jsonApiContext . ContextGraph ) ) ;
160160
161161 entity = await _create . CreateAsync ( entity ) ;
162162
@@ -170,7 +170,7 @@ public virtual async Task<IActionResult> PatchAsync(TId id, [FromBody] T entity)
170170 if ( entity == null )
171171 return UnprocessableEntity ( ) ;
172172 if ( _jsonApiContext . Options . ValidateModelState && ! ModelState . IsValid )
173- return BadRequest ( ModelState . ConvertToErrorCollection ( ) ) ;
173+ return BadRequest ( ModelState . ConvertToErrorCollection ( _jsonApiContext . ContextGraph ) ) ;
174174
175175 var updatedEntity = await _update . UpdateAsync ( id , entity ) ;
176176
0 commit comments