using System.Data; using Dapper; using PlotLine.Models; namespace PlotLine.Data; public interface IPlotLineWorkspaceRepository { Task GetAsync(int projectId, int? bookId, int? scenarioId); } public sealed class PlotLineWorkspaceRepository(ISqlConnectionFactory connectionFactory) : IPlotLineWorkspaceRepository { public async Task GetAsync(int projectId, int? bookId, int? scenarioId) { using var connection = connectionFactory.CreateConnection(); using var results = await connection.QueryMultipleAsync( "dbo.PlotLineWorkspace_Get", new { ProjectID = projectId, BookID = bookId, ScenarioID = scenarioId }, commandType: CommandType.StoredProcedure); return new PlotLineWorkspaceData { PlotLines = (await results.ReadAsync()).AsList(), Threads = (await results.ReadAsync()).AsList(), Contributions = (await results.ReadAsync()).AsList(), Targets = (await results.ReadAsync()).AsList(), Dependencies = (await results.ReadAsync()).AsList(), AttributionScenes = (await results.ReadAsync()).AsList(), Suggestions = (await results.ReadAsync()).AsList() }; } }