42 lines
1.8 KiB
C#
42 lines
1.8 KiB
C#
using System.Data;
|
|
using Dapper;
|
|
using PlotLine.Models;
|
|
|
|
namespace PlotLine.Data;
|
|
|
|
public sealed class StoryPointHistory
|
|
{
|
|
public IReadOnlyList<CharacterKnowledgeItem> Knowledge { get; init; } = [];
|
|
public IReadOnlyList<SceneAssetLocation> AssetLocations { get; init; } = [];
|
|
public IReadOnlyList<AssetCustodyEvent> Custody { get; init; } = [];
|
|
public IReadOnlyList<AssetCustodyCharacter> Custodians { get; init; } = [];
|
|
public IReadOnlyList<PlotThread> Threads { get; init; } = [];
|
|
public IReadOnlyList<ThreadEvent> ThreadEvents { get; init; } = [];
|
|
}
|
|
|
|
public interface IStoryPointRepository
|
|
{
|
|
Task<StoryPointHistory> GetHistoryAsync(int projectId, int sceneId);
|
|
}
|
|
|
|
public sealed class StoryPointRepository(ISqlConnectionFactory connections,IConfiguration? paragraphConfiguration=null) : IStoryPointRepository
|
|
{
|
|
public async Task<StoryPointHistory> 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);
|
|
var history=new StoryPointHistory
|
|
{
|
|
Knowledge = (await rows.ReadAsync<CharacterKnowledgeItem>()).ToList(),
|
|
AssetLocations = (await rows.ReadAsync<SceneAssetLocation>()).ToList(),
|
|
Custody = (await rows.ReadAsync<AssetCustodyEvent>()).ToList(),
|
|
Custodians = (await rows.ReadAsync<AssetCustodyCharacter>()).ToList(),
|
|
Threads = (await rows.ReadAsync<PlotThread>()).ToList(),
|
|
ThreadEvents = (await rows.ReadAsync<ThreadEvent>()).ToList()
|
|
};
|
|
await ParagraphEvidenceProjection.Apply(connection,paragraphConfiguration,history.Knowledge);
|
|
return history;
|
|
}
|
|
}
|