Refactored database registration to allow postgres to use internal representations for afster performance

This commit is contained in:
Khwezi Mngoma
2026-05-28 09:05:49 +02:00
parent 902942eee6
commit 2a0b34c730
20 changed files with 441 additions and 116 deletions
@@ -228,8 +228,8 @@ public sealed class ProductService(IDbContextFactory<MidrandBooksDbContext> cont
{
try
{
var fromDate = range.From.ToDateTime(TimeOnly.MinValue);
var toDate = range.To.ToDateTime(TimeOnly.MaxValue);
var fromDate = range.From.ToDateTime(TimeOnly.MinValue, DateTimeKind.Utc);
var toDate = range.To.ToDateTime(TimeOnly.MaxValue, DateTimeKind.Utc);
await using var context = await contextFactory.CreateDbContextAsync(cancellationToken);
@@ -244,7 +244,7 @@ public sealed class ProductService(IDbContextFactory<MidrandBooksDbContext> cont
.AsSplitQuery()
.ToArrayAsync(cancellationToken);
return await context.SaveChangesAsync(cancellationToken) > 0
return products?.Length > 0
? Result.Ok(products.Select(p => p.ToModel()).ToArray())
: Result.Fail<Product[]>(new Error("Failed to retrieve products."));
}