Skip to content

Commit bf9af03

Browse files
Add Localize method to SDTs to convert UTC DateTimes to the context’s time zone after deserialization
1 parent 6cadb30 commit bf9af03

File tree

4 files changed

+29
-1
lines changed

4 files changed

+29
-1
lines changed

dotnet/src/dotnetcore/GxClasses.Web/Middleware/GXRestServices.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,18 @@ internal void Initialize()
8787
ServiceHeaders();
8888
}
8989

90+
protected T ToInternalModel<T>(GxGenericCollectionItem<T> restSDT) where T : GxUserType, new()
91+
{
92+
if (restSDT != null)
93+
{
94+
restSDT.Sdt.Localize(context);
95+
return restSDT.InternalSdt;
96+
}
97+
else
98+
{
99+
return null;
100+
}
101+
}
90102
protected void Cleanup()
91103
{
92104
if (runAsMain)

dotnet/src/dotnetframework/GxClasses/Domain/GxCollections.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2051,6 +2051,10 @@ public void SetPropertyValue(string propertyName, object propertyValue)
20512051
{
20522052
GetType().GetProperty($"gxTpr_{propertyName}").SetValue(this, propertyValue);
20532053
}
2054+
2055+
public virtual void Localize(IGxContext context)
2056+
{
2057+
}
20542058
}
20552059
public class GXTypeInfo
20562060
{

dotnet/src/dotnetframework/GxClasses/Domain/GxGenericCollections.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,13 @@ public GXBaseCollection(GXBaseCollection<T> value)
122122
Add(item);
123123
}
124124
}
125-
125+
public void Localize(IGxContext context)
126+
{
127+
foreach (T item in this)
128+
{
129+
item.Localize(context);
130+
}
131+
}
126132
protected CollectionBase jsonArr
127133
{
128134
get

dotnet/src/dotnetframework/GxClasses/Model/GXSilentTrn.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -731,6 +731,12 @@ public GxUserType Sdt
731731
get { return sdt1; }
732732
set { sdt1 = (T)value; }
733733
}
734+
public T InternalSdt
735+
{
736+
get { return sdt1; }
737+
set { sdt1 = value; }
738+
}
739+
734740
#if NETCORE
735741
[JsonIgnore]
736742
#endif

0 commit comments

Comments
 (0)