@@ -191,7 +191,7 @@ public virtual void Write(AngularWriteConfiguration configuration)
191
191
nextCode = localCode . Method ( "map" , Code . Lambda ( "entry" , Code . This ( ) . Method ( "convertDate" , Code . Local ( "entry" ) ) ) ) ;
192
192
}
193
193
nextMethod . WithParameter ( Code . This ( ) . Method ( "fixUndefined" , nextCode ) ) ;
194
- if ( this . WriteDateFixes ( classTemplate , convertDateMethods , returnModel ) )
194
+ if ( this . WriteDateFixes ( classTemplate , convertDateMethods , returnModel , controllerOptions , relativeModelPath ) )
195
195
{
196
196
appendConvertDateMethod = true ;
197
197
string methodName = $ "convert{ returnModel . Name . ToPascalCase ( ) } Date";
@@ -497,7 +497,7 @@ public virtual void Write(AngularWriteConfiguration configuration)
497
497
. AddLine ( Code . Local ( "subject" ) . Method ( "next" ) . Close ( ) )
498
498
. AddLine ( Code . Local ( "subject" ) . Method ( "complete" ) . Close ( ) )
499
499
. AddLine ( Code . This ( ) . Field ( statusSubjectField ) . Method ( "next" , Code . Local ( connectionStatusEnum . Name ) . Field ( "connected" ) ) . Close ( ) ) ) )
500
- . Method ( "catch" , Code . Lambda ( errorCode ) ) . Close ( ) )
500
+ . Method ( "catch" , Code . Lambda ( "error" , errorCode ) ) . Close ( ) )
501
501
. AddLine ( Code . Return ( Code . Local ( "subject" ) ) )
502
502
) ) )
503
503
. WithCode ( createConnectionCode )
@@ -602,7 +602,7 @@ public virtual void Write(AngularWriteConfiguration configuration)
602
602
}
603
603
}
604
604
605
- private bool WriteDateFixes ( ClassTemplate classTemplate , List < MethodTemplate > convertDateMethods , ModelTransferObject model )
605
+ private bool WriteDateFixes ( ClassTemplate classTemplate , List < MethodTemplate > convertDateMethods , ModelTransferObject model , IOptions controllerOptions , string relativeModelPath )
606
606
{
607
607
if ( model == null )
608
608
{
@@ -613,6 +613,7 @@ private bool WriteDateFixes(ClassTemplate classTemplate, List<MethodTemplate> co
613
613
{
614
614
return true ;
615
615
}
616
+ this . AddUsing ( model , classTemplate , controllerOptions , relativeModelPath ) ;
616
617
bool hasLocalDateProperty = false ;
617
618
MethodTemplate convertDateMethodTemplate = classTemplate . AddMethod ( methodName , Code . Void ( ) ) . Private ( )
618
619
. WithParameter ( model . ToTemplate ( ) , "model" )
@@ -634,7 +635,7 @@ private bool WriteDateFixes(ClassTemplate classTemplate, List<MethodTemplate> co
634
635
}
635
636
else
636
637
{
637
- lineTemplate = assignTemplate . NullCoalescing ( Code . Local ( propertyName ) . Close ( ) ) ;
638
+ lineTemplate = assignTemplate . NullCoalescing ( Code . Local ( "model" ) . Field ( propertyName ) . Close ( ) ) ;
638
639
}
639
640
convertDateMethodTemplate . WithCode ( lineTemplate ) ;
640
641
}
@@ -653,18 +654,18 @@ private bool WriteDateFixes(ClassTemplate classTemplate, List<MethodTemplate> co
653
654
) ) )
654
655
) ;
655
656
}
656
- else if ( this . WriteDateFixes ( classTemplate , convertDateMethods , entryModel ) )
657
+ else if ( this . WriteDateFixes ( classTemplate , convertDateMethods , entryModel , controllerOptions , relativeModelPath ) )
657
658
{
658
659
hasLocalDateProperty = true ;
659
660
GenericAliasTransferObject aliasedType = model . Generics . FirstOrDefault ( x => x . Alias . Name == property . Type . Generics . Single ( ) . Alias . Name )
660
661
?? property . Type . Generics . Single ( ) ;
661
662
string convertMethodName = $ "convert{ aliasedType . Type . Name . ToPascalCase ( ) } Date";
662
- convertDateMethodTemplate . WithCode ( Code . Local ( "model" ) . Field ( propertyName + "?" ) . Method ( "forEach" , Code . Lambda ( "m" , Code . This ( ) . Method ( convertMethodName , Code . Local ( "m" ) ) ) ) ) ;
663
+ convertDateMethodTemplate . WithCode ( Code . Local ( "model" ) . Field ( propertyName + "?" ) . Method ( "forEach" , Code . Lambda ( "m" , Code . This ( ) . Method ( convertMethodName , Code . Local ( "m" ) ) ) ) . Close ( ) ) ;
663
664
}
664
665
}
665
666
else if ( propertyModel != null && propertyModel . Properties . Count > 0 )
666
667
{
667
- if ( this . WriteDateFixes ( classTemplate , convertDateMethods , propertyModel ) )
668
+ if ( this . WriteDateFixes ( classTemplate , convertDateMethods , propertyModel , controllerOptions , relativeModelPath ) )
668
669
{
669
670
hasLocalDateProperty = true ;
670
671
string convertMethodName = $ "convert{ property . Type . Name . ToPascalCase ( ) } Date";
0 commit comments