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 1
1
using System ;
2
2
using System . IO ;
3
3
using System . Threading . Tasks ;
4
- using JsonApiDotNetCore . Internal ;
5
- using JsonApiDotNetCore . Serialization ;
6
- using JsonApiDotNetCore . Services ;
4
+ using JsonApiDotNetCore . Models . Operations ;
7
5
using Microsoft . AspNetCore . Mvc . Formatters ;
8
- using Microsoft . Extensions . Logging ;
9
6
using Newtonsoft . Json ;
10
7
11
8
namespace JsonApiDotNetCore . Formatters
@@ -17,28 +14,26 @@ public interface IJsonApiOperationsReader
17
14
18
15
public class JsonApiOperationsReader : IJsonApiOperationsReader
19
16
{
20
- public JsonApiOperationsReader ( )
21
- {
22
- }
23
-
24
17
public Task < InputFormatterResult > ReadAsync ( InputFormatterContext context )
25
18
{
26
19
if ( context == null )
27
20
throw new ArgumentNullException ( nameof ( context ) ) ;
28
21
29
22
var request = context . HttpContext . Request ;
30
- if ( request . ContentLength == 0 )
23
+ if ( request . ContentLength == null || request . ContentLength == 0 )
31
24
return InputFormatterResult . FailureAsync ( ) ;
32
25
26
+ var body = GetRequestBody ( request . Body ) ;
27
+
28
+ var operations = JsonConvert . DeserializeObject < OperationsDocument > ( body ) ;
29
+
33
30
return InputFormatterResult . SuccessAsync ( null ) ;
34
31
}
35
32
36
33
private string GetRequestBody ( Stream body )
37
34
{
38
35
using ( var reader = new StreamReader ( body ) )
39
- {
40
36
return reader . ReadToEnd ( ) ;
41
- }
42
37
}
43
38
}
44
39
}
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