@@ -146,110 +146,103 @@ RecordDeclarationSyntax foreignKeyDto
146
146
result . AddProperty ( $ "_{ repo . Item2 } ") . SetType ( repo . Item1 ) . WithReadonlyValue ( ) ;
147
147
}
148
148
149
- if ( foreignRepos . Any ( ) )
150
- {
151
- //Generate GetFull methode
152
- var getMethode = baseRepo . GetMethodsWithAttributes < GetAttribute > ( repos ) . First ( ) ;
153
- result
154
- . AddMethod ( ApiUrls . GetFull , Accessibility . Public )
155
- . WithReturnTypeTask ( $ "{ dto . GetFullModelName ( ) } ")
156
- . MakeAsync ( )
157
- . AddParameter (
158
- "Guid" ,
159
- $ "{ dto . GetIdProperty ( baseDtos ) . GetPropertyName ( ) . GetParameterName ( ) } "
160
- )
161
- . WithBody ( x =>
149
+ //Generate GetFull methode
150
+ var getMethode = baseRepo . GetMethodsWithAttributes < GetAttribute > ( repos ) . First ( ) ;
151
+ result
152
+ . AddMethod ( ApiUrls . GetFull , Accessibility . Public )
153
+ . WithReturnTypeTask ( $ "{ dto . GetFullModelName ( ) } ")
154
+ . MakeAsync ( )
155
+ . AddParameter (
156
+ "Guid" ,
157
+ $ "{ dto . GetIdProperty ( baseDtos ) . GetPropertyName ( ) . GetParameterName ( ) } "
158
+ )
159
+ . WithBody ( x =>
160
+ {
161
+ x . AppendLine ( $ "{ dto . GetFullModelName ( ) } { dto . GetFullModelName ( ) } = new ();") ;
162
+ x . AppendLine (
163
+ $ "var { dto . GetName ( ) . GetParameterName ( ) } = await { getMethode . GetName ( ) } ({ dto . GetIdProperty ( baseDtos ) . GetPropertyName ( ) . GetParameterName ( ) } );"
164
+ ) ;
165
+ x . AppendLine (
166
+ $ "{ dto . GetFullModelName ( ) } .{ dto . GetName ( ) . GetParameterName ( ) } = { dto . GetName ( ) . GetParameterName ( ) } ;"
167
+ ) ;
168
+ foreach ( var repo in foreignRepos )
162
169
{
163
- x . AppendLine (
164
- $ "{ dto . GetFullModelName ( ) } { dto . GetFullModelName ( ) } = new ();"
165
- ) ;
166
- x . AppendLine (
167
- $ "var { dto . GetName ( ) . GetParameterName ( ) } = await { getMethode . GetName ( ) } ({ dto . GetIdProperty ( baseDtos ) . GetPropertyName ( ) . GetParameterName ( ) } );"
168
- ) ;
169
- x . AppendLine (
170
- $ "{ dto . GetFullModelName ( ) } .{ dto . GetName ( ) . GetParameterName ( ) } = { dto . GetName ( ) . GetParameterName ( ) } ;"
171
- ) ;
172
- foreach ( var repo in foreignRepos )
170
+ bool isNull = repo . propertySymbol . GetPropertyType ( ) . Contains ( "?" ) ;
171
+ string managerParametervalue = isNull
172
+ ? repo . propertySymbol . GetPropertyName ( ) + ".Value"
173
+ : repo . propertySymbol . GetPropertyName ( ) ;
174
+ string returnLine =
175
+ $ "{ dto . GetFullModelName ( ) } .{ repo . propertySymbol . GetFullModelNameFromProperty ( ) } = ({ repo . foreignKeyDto . GetFullModelName ( ) } )await _{ repo . repoName } .{ ApiUrls . GetFull } ({ dto . GetName ( ) . GetParameterName ( ) } .{ managerParametervalue } );";
176
+ if ( isNull )
177
+ {
178
+ x . If (
179
+ $ "{ dto . GetName ( ) . GetParameterName ( ) } .{ repo . propertySymbol . GetPropertyName ( ) } .HasValue"
180
+ )
181
+ . WithBody ( x =>
182
+ {
183
+ x . AppendLine ( returnLine ) ;
184
+ } )
185
+ . EndIf ( ) ;
186
+ }
187
+ else
173
188
{
174
- bool isNull = repo . propertySymbol . GetPropertyType ( ) . Contains ( "?" ) ;
175
- string managerParametervalue = isNull
176
- ? repo . propertySymbol . GetPropertyName ( ) + ".Value"
177
- : repo . propertySymbol . GetPropertyName ( ) ;
178
- string returnLine =
179
- $ "{ dto . GetFullModelName ( ) } .{ repo . propertySymbol . GetFullModelNameFromProperty ( ) } = ({ repo . foreignKeyDto . GetFullModelName ( ) } )await _{ repo . repoName } .{ ApiUrls . GetFull } ({ dto . GetName ( ) . GetParameterName ( ) } .{ managerParametervalue } );";
180
- if ( isNull )
181
- {
182
- x . If (
183
- $ "{ dto . GetName ( ) . GetParameterName ( ) } .{ repo . propertySymbol . GetPropertyName ( ) } .HasValue"
184
- )
185
- . WithBody ( x =>
186
- {
187
- x . AppendLine ( returnLine ) ;
188
- } )
189
- . EndIf ( ) ;
190
- }
191
- else
192
- {
193
- x . If (
194
- $ "{ dto . GetName ( ) . GetParameterName ( ) } .{ repo . propertySymbol . GetPropertyName ( ) } != default"
195
- )
196
- . WithBody ( x =>
197
- {
198
- x . AppendLine ( returnLine ) ;
199
- } )
200
- . EndIf ( ) ;
201
- }
189
+ x . If (
190
+ $ "{ dto . GetName ( ) . GetParameterName ( ) } .{ repo . propertySymbol . GetPropertyName ( ) } != default"
191
+ )
192
+ . WithBody ( x =>
193
+ {
194
+ x . AppendLine ( returnLine ) ;
195
+ } )
196
+ . EndIf ( ) ;
202
197
}
198
+ }
203
199
204
- x . AppendLine ( $ "return { dto . GetFullModelName ( ) } ;") ;
205
- } )
206
- . AddAttribute ( typeof ( GetFullAttribute ) . FullName ) ;
200
+ x . AppendLine ( $ "return { dto . GetFullModelName ( ) } ;") ;
201
+ } )
202
+ . AddAttribute ( typeof ( GetFullAttribute ) . FullName ) ;
207
203
208
- intf . AddMethod ( ApiUrls . GetFull )
209
- . WithReturnTypeTask ( $ "{ dto . GetFullModelName ( ) } ")
210
- . Abstract ( )
211
- . AddParameter (
212
- "Guid" ,
213
- $ "{ dto . GetIdProperty ( baseDtos ) . GetPropertyName ( ) . GetParameterName ( ) } "
214
- )
215
- . AddAttribute ( typeof ( GetFullAttribute ) . FullName ) ;
204
+ intf . AddMethod ( ApiUrls . GetFull )
205
+ . WithReturnTypeTask ( $ "{ dto . GetFullModelName ( ) } ")
206
+ . Abstract ( )
207
+ . AddParameter (
208
+ "Guid" ,
209
+ $ "{ dto . GetIdProperty ( baseDtos ) . GetPropertyName ( ) . GetParameterName ( ) } "
210
+ )
211
+ . AddAttribute ( typeof ( GetFullAttribute ) . FullName ) ;
216
212
217
- string returnName = dto . GetFullModelName ( ) . GetParameterName ( ) + "s" ;
213
+ string returnName = dto . GetFullModelName ( ) . GetParameterName ( ) + "s" ;
218
214
219
- //Generate GetAllFull methode
220
- var getAllMethode = baseRepo
221
- . GetMethodsWithAttributes < GetAllAttribute > ( repos )
222
- . First ( ) ;
223
- result
224
- . AddMethod ( ApiUrls . GetAllFull , Accessibility . Public )
225
- . WithReturnTypeTaskList ( $ "{ dto . GetFullModelName ( ) } ")
226
- . MakeAsync ( )
227
- . WithBody ( x =>
228
- {
229
- x . AppendLine ( $ "List<{ dto . GetFullModelName ( ) } > { returnName } = new ();") ;
230
- x . AppendLine (
231
- $ "var { dto . GetName ( ) . GetParameterName ( ) } s = await { getAllMethode . GetName ( ) } ();"
232
- ) ;
233
- x . ForEach (
234
- $ "var { dto . GetName ( ) . GetParameterName ( ) } ",
235
- $ "{ dto . GetName ( ) . GetParameterName ( ) } s"
236
- )
237
- . WithBody ( x =>
238
- {
239
- x . AppendLine (
240
- $ "{ returnName } .Add(await { ApiUrls . GetFull } ({ dto . GetName ( ) . GetParameterName ( ) } .{ dto . GetIdPropertyMethodeName ( baseDtos ) } ));"
241
- ) ;
242
- } ) ;
215
+ //Generate GetAllFull methode
216
+ var getAllMethode = baseRepo . GetMethodsWithAttributes < GetAllAttribute > ( repos ) . First ( ) ;
217
+ result
218
+ . AddMethod ( ApiUrls . GetAllFull , Accessibility . Public )
219
+ . WithReturnTypeTaskList ( $ "{ dto . GetFullModelName ( ) } ")
220
+ . MakeAsync ( )
221
+ . WithBody ( x =>
222
+ {
223
+ x . AppendLine ( $ "List<{ dto . GetFullModelName ( ) } > { returnName } = new ();") ;
224
+ x . AppendLine (
225
+ $ "var { dto . GetName ( ) . GetParameterName ( ) } s = await { getAllMethode . GetName ( ) } ();"
226
+ ) ;
227
+ x . ForEach (
228
+ $ "var { dto . GetName ( ) . GetParameterName ( ) } ",
229
+ $ "{ dto . GetName ( ) . GetParameterName ( ) } s"
230
+ )
231
+ . WithBody ( x =>
232
+ {
233
+ x . AppendLine (
234
+ $ "{ returnName } .Add(await { ApiUrls . GetFull } ({ dto . GetName ( ) . GetParameterName ( ) } .{ dto . GetIdPropertyMethodeName ( baseDtos ) } ));"
235
+ ) ;
236
+ } ) ;
243
237
244
- x . AppendLine ( $ "return { returnName } ;") ;
245
- } )
246
- . AddAttribute ( typeof ( GetAllFullAttribute ) . FullName ) ;
238
+ x . AppendLine ( $ "return { returnName } ;") ;
239
+ } )
240
+ . AddAttribute ( typeof ( GetAllFullAttribute ) . FullName ) ;
247
241
248
- intf . AddMethod ( ApiUrls . GetAllFull )
249
- . Abstract ( )
250
- . WithReturnTypeTaskList ( $ "{ dto . GetFullModelName ( ) } ")
251
- . AddAttribute ( typeof ( GetAllFullAttribute ) . FullName ) ;
252
- }
242
+ intf . AddMethod ( ApiUrls . GetAllFull )
243
+ . Abstract ( )
244
+ . WithReturnTypeTaskList ( $ "{ dto . GetFullModelName ( ) } ")
245
+ . AddAttribute ( typeof ( GetAllFullAttribute ) . FullName ) ;
253
246
254
247
//Add abstract methods
255
248
result
0 commit comments