using System.Data; using Dapper; using PlotLine.Models; namespace PlotLine.Data; public sealed class StoryPointHistory { public IReadOnlyList Knowledge { get; init; } = []; public IReadOnlyList AssetLocations { get; init; } = []; public IReadOnlyList Custody { get; init; } = []; public IReadOnlyList Custodians { get; init; } = []; public IReadOnlyList Threads { get; init; } = []; public IReadOnlyList ThreadEvents { get; init; } = []; } public interface IStoryPointRepository { Task GetHistoryAsync(int projectId, int sceneId); } public sealed class StoryPointRepository(ISqlConnectionFactory connections) : IStoryPointRepository { public async Task GetHistoryAsync(int projectId, int sceneId) { using var connection = connections.CreateConnection(); using var rows = await connection.QueryMultipleAsync("dbo.StoryPoint_GetHistory", new { ProjectID = projectId, SceneID = sceneId }, commandType: CommandType.StoredProcedure); return new StoryPointHistory { Knowledge = (await rows.ReadAsync()).ToList(), AssetLocations = (await rows.ReadAsync()).ToList(), Custody = (await rows.ReadAsync()).ToList(), Custodians = (await rows.ReadAsync()).ToList(), Threads = (await rows.ReadAsync()).ToList(), ThreadEvents = (await rows.ReadAsync()).ToList() }; } }