@@ -39,8 +39,11 @@ public static Content BuildEntity(DocumentDto dto, IContentType? contentType)
3939
4040 content . CreatorId = nodeDto . UserId ?? Constants . Security . UnknownUserId ;
4141 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 ) ;
4447
4548 content . Published = dto . Published ;
4649 content . Edited = dto . Edited ;
@@ -52,7 +55,7 @@ public static Content BuildEntity(DocumentDto dto, IContentType? contentType)
5255 content . PublishedVersionId = publishedVersionDto . Id ;
5356 if ( dto . Published )
5457 {
55- content . PublishDate = publishedVersionDto . ContentVersionDto . VersionDate ;
58+ content . PublishDate = DateTime . SpecifyKind ( publishedVersionDto . ContentVersionDto . VersionDate , DateTimeKind . Local ) ;
5659 content . PublishName = publishedVersionDto . ContentVersionDto . Text ;
5760 content . PublisherId = publishedVersionDto . ContentVersionDto . UserId ;
5861 }
@@ -71,7 +74,7 @@ public static Content BuildEntity(DocumentDto dto, IContentType? contentType)
7174 }
7275
7376 /// <summary>
74- /// Builds an IMedia item from a dto and content type.
77+ /// Builds a Media item from a dto and content type.
7578 /// </summary>
7679 public static Core . Models . Media BuildEntity ( ContentDto dto , IMediaType ? contentType )
7780 {
@@ -97,8 +100,8 @@ public static Core.Models.Media BuildEntity(ContentDto dto, IMediaType? contentT
97100
98101 content . CreatorId = nodeDto . UserId ?? Constants . Security . UnknownUserId ;
99102 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 ) ;
102105
103106 // reset dirty initial properties (U4-1946)
104107 content . ResetDirtyProperties ( false ) ;
@@ -111,7 +114,7 @@ public static Core.Models.Media BuildEntity(ContentDto dto, IMediaType? contentT
111114 }
112115
113116 /// <summary>
114- /// Builds an IMedia item from a dto and content type.
117+ /// Builds a Member item from a dto and member type.
115118 /// </summary>
116119 public static Member BuildEntity ( MemberDto dto , IMemberType ? contentType )
117120 {
@@ -126,7 +129,9 @@ public static Member BuildEntity(MemberDto dto, IMemberType? contentType)
126129
127130 content . Id = dto . NodeId ;
128131 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 ;
130135 content . PasswordConfiguration = dto . PasswordConfig ;
131136 content . Key = nodeDto . UniqueId ;
132137 content . VersionId = contentVersionDto . Id ;
@@ -140,14 +145,20 @@ public static Member BuildEntity(MemberDto dto, IMemberType? contentType)
140145
141146 content . CreatorId = nodeDto . UserId ?? Constants . Security . UnknownUserId ;
142147 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 ) ;
145150 content . FailedPasswordAttempts = dto . FailedPasswordAttempts ?? default ;
146151 content . IsLockedOut = dto . IsLockedOut ;
147152 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 ;
151162
152163 // reset dirty initial properties (U4-1946)
153164 content . ResetDirtyProperties ( false ) ;
@@ -186,7 +197,7 @@ public static DocumentDto BuildDto(IContent entity, Guid objectType)
186197 new ContentScheduleDto
187198 {
188199 Action = x . Action . ToString ( ) ,
189- Date = x . Date ,
200+ Date = DateTime . SpecifyKind ( x . Date , DateTimeKind . Local ) ,
190201 NodeId = entity . Id ,
191202 LanguageId = languageRepository . GetIdByIsoCode ( x . Culture , false ) ,
192203 Id = x . Id ,
@@ -261,7 +272,7 @@ private static NodeDto BuildNodeDto(IContentBase entity, Guid objectType)
261272 UserId = entity . CreatorId ,
262273 Text = entity . Name ,
263274 NodeObjectType = objectType ,
264- CreateDate = entity . CreateDate ,
275+ CreateDate = DateTime . SpecifyKind ( entity . CreateDate , DateTimeKind . Local ) ,
265276 } ;
266277
267278 return dto ;
@@ -275,7 +286,7 @@ private static ContentVersionDto BuildContentVersionDto(IContentBase entity, Con
275286 {
276287 Id = entity . VersionId ,
277288 NodeId = entity . Id ,
278- VersionDate = entity . UpdateDate ,
289+ VersionDate = DateTime . SpecifyKind ( entity . UpdateDate , DateTimeKind . Local ) ,
279290 UserId = entity . WriterId ,
280291 Current = true , // always building the current one
281292 Text = entity . Name ,
0 commit comments