File tree Expand file tree Collapse file tree 2 files changed +15
-11
lines changed Expand file tree Collapse file tree 2 files changed +15
-11
lines changed Original file line number Diff line number Diff line change 11using System ;
22using System . IO ;
33using System . Threading . Tasks ;
4- using JsonApiDotNetCore . Internal ;
5- using JsonApiDotNetCore . Serialization ;
6- using JsonApiDotNetCore . Services ;
4+ using JsonApiDotNetCore . Models . Operations ;
75using Microsoft . AspNetCore . Mvc . Formatters ;
8- using Microsoft . Extensions . Logging ;
96using Newtonsoft . Json ;
107
118namespace JsonApiDotNetCore . Formatters
@@ -17,28 +14,26 @@ public interface IJsonApiOperationsReader
1714
1815 public class JsonApiOperationsReader : IJsonApiOperationsReader
1916 {
20- public JsonApiOperationsReader ( )
21- {
22- }
23-
2417 public Task < InputFormatterResult > ReadAsync ( InputFormatterContext context )
2518 {
2619 if ( context == null )
2720 throw new ArgumentNullException ( nameof ( context ) ) ;
2821
2922 var request = context . HttpContext . Request ;
30- if ( request . ContentLength == 0 )
23+ if ( request . ContentLength == null || request . ContentLength == 0 )
3124 return InputFormatterResult . FailureAsync ( ) ;
3225
26+ var body = GetRequestBody ( request . Body ) ;
27+
28+ var operations = JsonConvert . DeserializeObject < OperationsDocument > ( body ) ;
29+
3330 return InputFormatterResult . SuccessAsync ( null ) ;
3431 }
3532
3633 private string GetRequestBody ( Stream body )
3734 {
3835 using ( var reader = new StreamReader ( body ) )
39- {
4036 return reader . ReadToEnd ( ) ;
41- }
4237 }
4338 }
4439}
Original file line number Diff line number Diff line change 1+ using System . Collections . Generic ;
2+
3+ namespace JsonApiDotNetCore . Models . Operations
4+ {
5+ public class OperationsDocument
6+ {
7+ public List < Operation > Operations { get ; set ; }
8+ }
9+ }
You can’t perform that action at this time.
0 commit comments