blocker fix phase 4
This commit is contained in:
+6
-1
@@ -1,4 +1,5 @@
|
||||
using Baya.Domain.Entities.Booking;
|
||||
using Baya.Infrastructure.Persistence.ValueConversion;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
|
||||
@@ -16,7 +17,11 @@ internal sealed class BookingRequestConfig : IEntityTypeConfiguration<BookingReq
|
||||
builder.Property(r => r.CustomerNotes).HasMaxLength(1000);
|
||||
builder.Property(r => r.Status).HasMaxLength(50).IsRequired();
|
||||
builder.Property(r => r.NurseRejectionReason).HasMaxLength(500);
|
||||
builder.Property(r => r.NurseResponseDeadlineAt).IsRequired();
|
||||
|
||||
// datetime2 loses Kind on read (comes back Unspecified); re-tag as Utc so JSON serialization keeps
|
||||
// the trailing Z and clients don't misparse the deadline as local time (mvp/blocker-phases/04).
|
||||
builder.Property(r => r.NurseResponseDeadlineAt).HasConversion(new UtcDateTimeConverter()).IsRequired();
|
||||
builder.Property(r => r.PaymentDeadlineAt).HasConversion(new UtcDateTimeConverter());
|
||||
|
||||
// Inbox lists read on (party, status), actionable-first; the two deadline indexes let the expiry
|
||||
// sweep select stale rows through a covering index instead of scanning the table.
|
||||
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
|
||||
namespace Baya.Infrastructure.Persistence.ValueConversion;
|
||||
|
||||
/// <summary>
|
||||
/// SQL Server's <c>datetime2</c> carries no timezone, so EF's provider returns <see cref="DateTimeKind.Unspecified"/>
|
||||
/// on read even though the value was always written as UTC — leaving it that way makes System.Text.Json omit the
|
||||
/// trailing <c>Z</c>, and clients then misparse the instant as local time. Re-tags the <see cref="DateTimeKind"/> as
|
||||
/// <see cref="DateTimeKind.Utc"/> on read; the value itself is never altered.
|
||||
/// </summary>
|
||||
internal sealed class UtcDateTimeConverter()
|
||||
: ValueConverter<DateTime, DateTime>(
|
||||
v => v,
|
||||
v => DateTime.SpecifyKind(v, DateTimeKind.Utc));
|
||||
Reference in New Issue
Block a user