refactor(public): in-process ITrackDataService on server prerender; HTTP on WASM

This commit is contained in:
Daniel Harvey
2026-05-20 16:49:43 -04:00
parent 35099a54e5
commit e8072f8b17
7 changed files with 104 additions and 10 deletions
@@ -0,0 +1,25 @@
using DeepDrftModels.Entities;
using Models.Common;
using NetBlocks.Models;
namespace DeepDrftPublic.Client.Services;
/// <summary>
/// Track metadata fetch abstraction with two render-mode-specific implementations:
///
/// - Server prerender pass: <c>TrackDirectDataService</c> in the DeepDrftPublic host
/// resolves <see cref="DeepDrftData.ITrackService"/> in-process (EF Core / SQL) and
/// avoids a loopback HTTP hop.
/// - WASM interactive pass: <c>TrackClientDataService</c> in this assembly delegates
/// to <see cref="Clients.TrackClient"/> over HTTP.
///
/// Components inject this single seam so they do not branch on render mode.
/// </summary>
public interface ITrackDataService
{
Task<ApiResult<PagedResult<TrackEntity>>> GetPage(
int pageNumber,
int pageSize,
string? sortColumn = null,
bool sortDescending = false);
}
@@ -0,0 +1,28 @@
using DeepDrftModels.Entities;
using DeepDrftPublic.Client.Clients;
using Models.Common;
using NetBlocks.Models;
namespace DeepDrftPublic.Client.Services;
/// <summary>
/// WASM-side <see cref="ITrackDataService"/> that delegates to <see cref="TrackClient"/>
/// (HTTP to the <c>DeepDrft.API</c> backend). Used on the WASM interactive render pass;
/// the server prerender pass swaps in a direct, in-process implementation.
/// </summary>
public class TrackClientDataService : ITrackDataService
{
private readonly TrackClient _trackClient;
public TrackClientDataService(TrackClient trackClient)
{
_trackClient = trackClient;
}
public Task<ApiResult<PagedResult<TrackEntity>>> GetPage(
int pageNumber,
int pageSize,
string? sortColumn = null,
bool sortDescending = false)
=> _trackClient.GetPage(pageNumber, pageSize, sortColumn, sortDescending);
}