@@ -27,7 +27,7 @@ public JsonApiDeSerializer(
27
27
public object Deserialize ( string requestBody )
28
28
{
29
29
var document = JsonConvert . DeserializeObject < Document > ( requestBody ) ;
30
- var entity = DataToObject ( document . Data ) ;
30
+ var entity = DocumentToObject ( document . Data ) ;
31
31
return entity ;
32
32
}
33
33
@@ -46,30 +46,29 @@ public object DeserializeRelationship(string requestBody)
46
46
return new List < DocumentData > { data . ToObject < DocumentData > ( ) } ;
47
47
}
48
48
49
-
50
49
public List < TEntity > DeserializeList < TEntity > ( string requestBody )
51
50
{
52
51
var documents = JsonConvert . DeserializeObject < Documents > ( requestBody ) ;
53
52
54
53
var deserializedList = new List < TEntity > ( ) ;
55
54
foreach ( var data in documents . Data )
56
55
{
57
- var entity = DataToObject ( data ) ;
56
+ var entity = DocumentToObject ( data ) ;
58
57
deserializedList . Add ( ( TEntity ) entity ) ;
59
58
}
60
59
61
60
return deserializedList ;
62
61
}
63
62
64
- private object DataToObject ( DocumentData data )
63
+ private object DocumentToObject ( DocumentData data )
65
64
{
66
65
var contextEntity = _jsonApiContext . ContextGraph . GetContextEntity ( data . Type ) ;
67
66
_jsonApiContext . RequestEntity = contextEntity ;
68
67
69
68
var entity = Activator . CreateInstance ( contextEntity . EntityType ) ;
70
69
71
- entity = _setEntityAttributes ( entity , contextEntity , data . Attributes ) ;
72
- entity = _setRelationships ( entity , contextEntity , data . Relationships ) ;
70
+ entity = SetEntityAttributes ( entity , contextEntity , data . Attributes ) ;
71
+ entity = SetRelationships ( entity , contextEntity , data . Relationships ) ;
73
72
74
73
var identifiableEntity = ( IIdentifiable ) entity ;
75
74
@@ -79,7 +78,7 @@ private object DataToObject(DocumentData data)
79
78
return identifiableEntity ;
80
79
}
81
80
82
- private object _setEntityAttributes (
81
+ private object SetEntityAttributes (
83
82
object entity , ContextEntity contextEntity , Dictionary < string , object > attributeValues )
84
83
{
85
84
if ( attributeValues == null || attributeValues . Count == 0 )
@@ -99,13 +98,14 @@ private object _setEntityAttributes(
99
98
{
100
99
var convertedValue = TypeHelper . ConvertType ( newValue , entityProperty . PropertyType ) ;
101
100
entityProperty . SetValue ( entity , convertedValue ) ;
101
+ _jsonApiContext . AttributesToUpdate [ attr ] = convertedValue ;
102
102
}
103
103
}
104
104
105
105
return entity ;
106
106
}
107
107
108
- private object _setRelationships (
108
+ private object SetRelationships (
109
109
object entity ,
110
110
ContextEntity contextEntity ,
111
111
Dictionary < string , RelationshipData > relationships )
@@ -118,14 +118,14 @@ private object _setRelationships(
118
118
foreach ( var attr in contextEntity . Relationships )
119
119
{
120
120
entity = attr . IsHasOne
121
- ? _setHasOneRelationship ( entity , entityProperties , attr , contextEntity , relationships )
122
- : _setHasManyRelationship ( entity , entityProperties , attr , contextEntity , relationships ) ;
121
+ ? SetHasOneRelationship ( entity , entityProperties , attr , contextEntity , relationships )
122
+ : SetHasManyRelationship ( entity , entityProperties , attr , contextEntity , relationships ) ;
123
123
}
124
124
125
125
return entity ;
126
126
}
127
127
128
- private object _setHasOneRelationship ( object entity ,
128
+ private object SetHasOneRelationship ( object entity ,
129
129
PropertyInfo [ ] entityProperties ,
130
130
RelationshipAttribute attr ,
131
131
ContextEntity contextEntity ,
@@ -158,7 +158,7 @@ private object _setHasOneRelationship(object entity,
158
158
return entity ;
159
159
}
160
160
161
- private object _setHasManyRelationship ( object entity ,
161
+ private object SetHasManyRelationship ( object entity ,
162
162
PropertyInfo [ ] entityProperties ,
163
163
RelationshipAttribute attr ,
164
164
ContextEntity contextEntity ,
0 commit comments