@@ -39,8 +39,11 @@ public static Content BuildEntity(DocumentDto dto, IContentType? contentType)
39
39
40
40
content . CreatorId = nodeDto . UserId ?? Constants . Security . UnknownUserId ;
41
41
content . WriterId = contentVersionDto . UserId ?? Constants . Security . UnknownUserId ;
42
- content . CreateDate = nodeDto . CreateDate ;
43
- content . UpdateDate = contentVersionDto . VersionDate ;
42
+
43
+ // Dates stored in the database are local server time, but for SQL Server, will be considered
44
+ // as DateTime.Kind = Utc. Fix this so we are consistent when later mapping to DataTimeOffset.
45
+ content . CreateDate = DateTime . SpecifyKind ( nodeDto . CreateDate , DateTimeKind . Local ) ;
46
+ content . UpdateDate = DateTime . SpecifyKind ( contentVersionDto . VersionDate , DateTimeKind . Local ) ;
44
47
45
48
content . Published = dto . Published ;
46
49
content . Edited = dto . Edited ;
@@ -52,7 +55,7 @@ public static Content BuildEntity(DocumentDto dto, IContentType? contentType)
52
55
content . PublishedVersionId = publishedVersionDto . Id ;
53
56
if ( dto . Published )
54
57
{
55
- content . PublishDate = publishedVersionDto . ContentVersionDto . VersionDate ;
58
+ content . PublishDate = DateTime . SpecifyKind ( publishedVersionDto . ContentVersionDto . VersionDate , DateTimeKind . Local ) ;
56
59
content . PublishName = publishedVersionDto . ContentVersionDto . Text ;
57
60
content . PublisherId = publishedVersionDto . ContentVersionDto . UserId ;
58
61
}
@@ -71,7 +74,7 @@ public static Content BuildEntity(DocumentDto dto, IContentType? contentType)
71
74
}
72
75
73
76
/// <summary>
74
- /// Builds an IMedia item from a dto and content type.
77
+ /// Builds a Media item from a dto and content type.
75
78
/// </summary>
76
79
public static Core . Models . Media BuildEntity ( ContentDto dto , IMediaType ? contentType )
77
80
{
@@ -97,8 +100,8 @@ public static Core.Models.Media BuildEntity(ContentDto dto, IMediaType? contentT
97
100
98
101
content . CreatorId = nodeDto . UserId ?? Constants . Security . UnknownUserId ;
99
102
content . WriterId = contentVersionDto . UserId ?? Constants . Security . UnknownUserId ;
100
- content . CreateDate = nodeDto . CreateDate ;
101
- content . UpdateDate = contentVersionDto . VersionDate ;
103
+ content . CreateDate = DateTime . SpecifyKind ( nodeDto . CreateDate , DateTimeKind . Local ) ;
104
+ content . UpdateDate = DateTime . SpecifyKind ( contentVersionDto . VersionDate , DateTimeKind . Local ) ;
102
105
103
106
// reset dirty initial properties (U4-1946)
104
107
content . ResetDirtyProperties ( false ) ;
@@ -111,7 +114,7 @@ public static Core.Models.Media BuildEntity(ContentDto dto, IMediaType? contentT
111
114
}
112
115
113
116
/// <summary>
114
- /// Builds an IMedia item from a dto and content type.
117
+ /// Builds a Member item from a dto and member type.
115
118
/// </summary>
116
119
public static Member BuildEntity ( MemberDto dto , IMemberType ? contentType )
117
120
{
@@ -126,7 +129,9 @@ public static Member BuildEntity(MemberDto dto, IMemberType? contentType)
126
129
127
130
content . Id = dto . NodeId ;
128
131
content . SecurityStamp = dto . SecurityStampToken ;
129
- content . EmailConfirmedDate = dto . EmailConfirmedDate ;
132
+ content . EmailConfirmedDate = dto . EmailConfirmedDate . HasValue
133
+ ? DateTime . SpecifyKind ( dto . EmailConfirmedDate . Value , DateTimeKind . Local )
134
+ : null ;
130
135
content . PasswordConfiguration = dto . PasswordConfig ;
131
136
content . Key = nodeDto . UniqueId ;
132
137
content . VersionId = contentVersionDto . Id ;
@@ -140,14 +145,20 @@ public static Member BuildEntity(MemberDto dto, IMemberType? contentType)
140
145
141
146
content . CreatorId = nodeDto . UserId ?? Constants . Security . UnknownUserId ;
142
147
content . WriterId = contentVersionDto . UserId ?? Constants . Security . UnknownUserId ;
143
- content . CreateDate = nodeDto . CreateDate ;
144
- content . UpdateDate = contentVersionDto . VersionDate ;
148
+ content . CreateDate = DateTime . SpecifyKind ( nodeDto . CreateDate , DateTimeKind . Local ) ;
149
+ content . UpdateDate = DateTime . SpecifyKind ( contentVersionDto . VersionDate , DateTimeKind . Local ) ;
145
150
content . FailedPasswordAttempts = dto . FailedPasswordAttempts ?? default ;
146
151
content . IsLockedOut = dto . IsLockedOut ;
147
152
content . IsApproved = dto . IsApproved ;
148
- content . LastLoginDate = dto . LastLoginDate ;
149
- content . LastLockoutDate = dto . LastLockoutDate ;
150
- content . LastPasswordChangeDate = dto . LastPasswordChangeDate ;
153
+ content . LastLockoutDate = dto . LastLockoutDate . HasValue
154
+ ? DateTime . SpecifyKind ( dto . LastLockoutDate . Value , DateTimeKind . Local )
155
+ : null ;
156
+ content . LastLoginDate = dto . LastLoginDate . HasValue
157
+ ? DateTime . SpecifyKind ( dto . LastLoginDate . Value , DateTimeKind . Local )
158
+ : null ;
159
+ content . LastPasswordChangeDate = dto . LastPasswordChangeDate . HasValue
160
+ ? DateTime . SpecifyKind ( dto . LastPasswordChangeDate . Value , DateTimeKind . Local )
161
+ : null ;
151
162
152
163
// reset dirty initial properties (U4-1946)
153
164
content . ResetDirtyProperties ( false ) ;
@@ -186,7 +197,7 @@ public static DocumentDto BuildDto(IContent entity, Guid objectType)
186
197
new ContentScheduleDto
187
198
{
188
199
Action = x . Action . ToString ( ) ,
189
- Date = x . Date ,
200
+ Date = DateTime . SpecifyKind ( x . Date , DateTimeKind . Local ) ,
190
201
NodeId = entity . Id ,
191
202
LanguageId = languageRepository . GetIdByIsoCode ( x . Culture , false ) ,
192
203
Id = x . Id ,
@@ -261,7 +272,7 @@ private static NodeDto BuildNodeDto(IContentBase entity, Guid objectType)
261
272
UserId = entity . CreatorId ,
262
273
Text = entity . Name ,
263
274
NodeObjectType = objectType ,
264
- CreateDate = entity . CreateDate ,
275
+ CreateDate = DateTime . SpecifyKind ( entity . CreateDate , DateTimeKind . Local ) ,
265
276
} ;
266
277
267
278
return dto ;
@@ -275,7 +286,7 @@ private static ContentVersionDto BuildContentVersionDto(IContentBase entity, Con
275
286
{
276
287
Id = entity . VersionId ,
277
288
NodeId = entity . Id ,
278
- VersionDate = entity . UpdateDate ,
289
+ VersionDate = DateTime . SpecifyKind ( entity . UpdateDate , DateTimeKind . Local ) ,
279
290
UserId = entity . WriterId ,
280
291
Current = true , // always building the current one
281
292
Text = entity . Name ,
0 commit comments