Fix #5205: specific the date time as UTC kind.

This commit is contained in:
Ben 2025-03-29 09:29:49 +08:00
parent 1770c1ee11
commit 1cba78cc4e

View File

@ -61,6 +61,9 @@ namespace Oqtane.Repository
public UserRole AddUserRole(UserRole userRole)
{
userRole.EffectiveDate = userRole.EffectiveDate.HasValue ? DateTime.SpecifyKind(userRole.EffectiveDate.Value, DateTimeKind.Utc) : userRole.EffectiveDate;
userRole.ExpiryDate = userRole.ExpiryDate.HasValue ? DateTime.SpecifyKind(userRole.ExpiryDate.Value, DateTimeKind.Utc) : userRole.ExpiryDate;
using var db = _dbContextFactory.CreateDbContext();
db.UserRole.Add(userRole);
db.SaveChanges();
@ -84,6 +87,9 @@ namespace Oqtane.Repository
public UserRole UpdateUserRole(UserRole userRole)
{
userRole.EffectiveDate = userRole.EffectiveDate.HasValue ? DateTime.SpecifyKind(userRole.EffectiveDate.Value, DateTimeKind.Utc) : userRole.EffectiveDate;
userRole.ExpiryDate = userRole.ExpiryDate.HasValue ? DateTime.SpecifyKind(userRole.ExpiryDate.Value, DateTimeKind.Utc) : userRole.ExpiryDate;
using var db = _dbContextFactory.CreateDbContext();
db.Entry(userRole).State = EntityState.Modified;
db.SaveChanges();