LockoutEnd sent with to Frontend as "01.01.0001 00:00:00 +00:00" even when is null on DB(Sql Server on my case)
Closed this issue · 1 comments
Hi everyone.
First of all, thanks to all people involved on JpProject development. Keep up the great job!
Not sure if this is something wrong on my end, but I am facing a situation where the "UserViewModel.LockoutEnd" (of type DateTimeOffset?) was sent to the angular client with the default value from DateTimeOffset (something like 01.01.0001 00:00:00 +00:00) instead of null (as it is stored in Database).
This ends up creating some trouble because if the user saves the changes, then "01.01.0001 00:00:00 +00:00" will be stored on the database, and later I start getting further errors (The UTC representation of the date '1/1/0001' falls outside the year range 1-9999.) when calling the Details(admin/users/{username}). Automapper.
For now I made an solution that is not so nice, but did the job... Basically when the Automapper configuration is set, I added the following ValueTransformer(to set as null when the Value is the default value of DateTimeOffset.
configurationExpression.ValueTransformers.Add<DateTimeOffset?>(value => value.HasValue && value.Value == default(DateTimeOffset)?null:value);
It is a minor issue, but maybe someone already stumble at it, or it might be even something I added myself when I am playing with it.
BR
Pedro
Hi there,
It makes sense. It suppose to be null instead a 01/01/0001. You did a good solution. I'll also change the frontend to send null instead.
Another change could be on basis classes, which can check if the Lockout date is a future date. Since it doesn't make sense to be in the past.