File tree Expand file tree Collapse file tree 3 files changed +15
-7
lines changed
Examples/JsonApiDotNetCoreExample/Models
JsonApiDotNetCore/Serialization
test/JsonApiDotNetCoreExampleTests/Acceptance Expand file tree Collapse file tree 3 files changed +15
-7
lines changed Original file line number Diff line number Diff line change 1- using System ;
1+ using System ;
22using System . Collections . Generic ;
33using JsonApiDotNetCore . Models ;
44
@@ -26,12 +26,12 @@ public TodoItem()
2626 [ Attr ( "achieved-date" , isFilterable : false , isSortable : false ) ]
2727 public DateTime ? AchievedDate { get ; set ; }
2828
29-
3029 [ Attr ( "updated-date" ) ]
3130 public DateTime ? UpdatedDate { get ; set ; }
3231
33-
34-
32+ [ Attr ( "offset-date" ) ]
33+ public DateTimeOffset ? OffsetDate { get ; set ; }
34+
3535 public int ? OwnerId { get ; set ; }
3636 public int ? AssigneeId { get ; set ; }
3737 public Guid ? CollectionId { get ; set ; }
Original file line number Diff line number Diff line change 11using System ;
22using System . Collections . Generic ;
3+ using System . IO ;
34using System . Linq ;
45using System . Reflection ;
56using JsonApiDotNetCore . Extensions ;
@@ -36,8 +37,12 @@ public object Deserialize(string requestBody)
3637 {
3738 try
3839 {
39- var bodyJToken = JToken . Parse ( requestBody ) ;
40-
40+ JToken bodyJToken ;
41+ using ( JsonReader jsonReader = new JsonTextReader ( new StringReader ( requestBody ) ) )
42+ {
43+ jsonReader . DateParseHandling = DateParseHandling . None ;
44+ bodyJToken = JToken . Load ( jsonReader ) ;
45+ }
4146 if ( RequestIsOperation ( bodyJToken ) )
4247 {
4348 _jsonApiContext . IsBulkOperationRequest = true ;
Original file line number Diff line number Diff line change @@ -452,6 +452,7 @@ public async Task Can_Post_TodoItem()
452452 _context . SaveChanges ( ) ;
453453
454454 var todoItem = _todoItemFaker . Generate ( ) ;
455+ var nowOffset = new DateTimeOffset ( ) ;
455456 var content = new
456457 {
457458 data = new
@@ -461,7 +462,8 @@ public async Task Can_Post_TodoItem()
461462 {
462463 { "description" , todoItem . Description } ,
463464 { "ordinal" , todoItem . Ordinal } ,
464- { "created-date" , todoItem . CreatedDate }
465+ { "created-date" , todoItem . CreatedDate } ,
466+ { "offset-date" , nowOffset }
465467 } ,
466468 relationships = new
467469 {
@@ -494,6 +496,7 @@ public async Task Can_Post_TodoItem()
494496 Assert . Equal ( HttpStatusCode . Created , response . StatusCode ) ;
495497 Assert . Equal ( todoItem . Description , deserializedBody . Description ) ;
496498 Assert . Equal ( todoItem . CreatedDate . ToString ( "G" ) , deserializedBody . CreatedDate . ToString ( "G" ) ) ;
499+ Assert . Equal ( nowOffset . ToString ( "yyyy-MM-ddTHH:mm:ssK" ) , deserializedBody . OffsetDate ? . ToString ( "yyyy-MM-ddTHH:mm:ssK" ) ) ;
497500 Assert . Null ( deserializedBody . AchievedDate ) ;
498501 }
499502
You can’t perform that action at this time.
0 commit comments