Code: Select all
DateTime test = new DateTime(2025, 4, 9, 4, 0, 0); //instead of the it would be DateTime.UtcNow
TimeZoneInfo timeZoneInfo = getUserTimeZoneInfo(); //Converting to toronto time EDT going on
DateTime currentUserTime = ConvertToUserTimeZone(test, timeZoneInfo);
var result = (from message in dbContext.Messages
join userMap in otherContext.UserMessageMappings
.Where(u => u.UserEmail == currentUserEmail)
on message.Id equals userMap.MessageId into messageJoin
from userMapping in messageJoin.DefaultIfEmpty()
where message.IsDeleted == false
select new MessageDto
{
Id = message.Id,
FileName = message.FileName,
EffectiveDate = message.EffectiveDate,
ExpirationDate = message.ExpirationDate,
Title = message.Title,
Content = message.Content,
SecondaryTitle = message.SecondaryTitle,
SecondaryContent = message.SecondaryContent,
Region = message.Region,
CreatedBy = message.CreatedBy,
CreatedAt = message.CreatedAt
})
.AsEnumerable()
.Where(msg => msg.ExpirationDate.HasValue && msg.EffectiveDate.HasValue
currentUserTime = ConvertToUserTimeZone(msg.EffectiveDate.Value, timeZoneInfo))
.ToList();
Code: Select all
ExpirationDate: 2025-04-10 23:59:59.0000000
EffectiveDate: 2025-04-09 00:00:00.0000000
Code: Select all
ExpirationDate: 2025-04-10 23:59:59.0000000
EffectiveDate: 2025-04-09 00:00:00.0000000
Code: Select all
DateTime test = new DateTime(2025, 4, 9, 4, 0, 0);
Code: Select all
2025-04-09 04:00:00.0000000
DateTime currentUserTime = ConvertToUserTimeZone(test, timeZoneInfo);
Code: Select all
currentUserTime >= ConvertToUserTimeZone(msg.EffectiveDate.Value, timeZoneInfo) // returns true but
currentUserTime