17 lines
1.5 KiB
C#
17 lines
1.5 KiB
C#
using System.Data;
|
|
using Dapper;
|
|
using PlotLine.Services;
|
|
namespace PlotLine.Data;
|
|
public interface IIntentAssessmentRepository
|
|
{
|
|
Task<IntentAssessment?> Read(int user,int scene,string? hash=null);
|
|
Task Save(int user,int scene,string hash,string json,string model,Guid? reservation=null,Guid? lease=null);
|
|
Task Decide(int user,int scene,string hash,string key,string decision);
|
|
}
|
|
public sealed class IntentAssessmentRepository(ISqlConnectionFactory factory):IIntentAssessmentRepository
|
|
{
|
|
public async Task<IntentAssessment?> Read(int user,int scene,string? hash=null){using var db=factory.CreateConnection();return await db.QuerySingleOrDefaultAsync<IntentAssessment>("dbo.WritingIntentAssessment",new{Action="Read",UserID=user,SceneID=scene,InputHash=hash},commandType:CommandType.StoredProcedure);}
|
|
public async Task Save(int user,int scene,string hash,string json,string model,Guid? reservation=null,Guid? lease=null){using var db=factory.CreateConnection();await db.ExecuteAsync("dbo.WritingIntentAssessment",new{Action="Save",UserID=user,SceneID=scene,InputHash=hash,ResultsJson=json,Model=model,AiReservationID=reservation,AiLeaseToken=lease},commandType:CommandType.StoredProcedure);}
|
|
public async Task Decide(int user,int scene,string hash,string key,string decision){using var db=factory.CreateConnection();await db.ExecuteAsync("dbo.WritingIntentAssessment",new{Action="Decide",UserID=user,SceneID=scene,InputHash=hash,Key=key,Decision=decision},commandType:CommandType.StoredProcedure);}
|
|
}
|