Saving snapshots
This commit is contained in:
@@ -1,9 +1,11 @@
|
||||
using Dapper;
|
||||
using Shogi.Api.Repositories.Dto;
|
||||
using Shogi.Api.Repositories.Dto.SessionState;
|
||||
using Shogi.Contracts.Api.Commands;
|
||||
using Shogi.Domain.Aggregates;
|
||||
using System.Data;
|
||||
using System.Data.SqlClient;
|
||||
using System.Text.Json;
|
||||
|
||||
namespace Shogi.Api.Repositories;
|
||||
|
||||
@@ -81,4 +83,19 @@ public class SessionRepository(IConfiguration configuration)
|
||||
},
|
||||
commandType: CommandType.StoredProcedure);
|
||||
}
|
||||
|
||||
public async Task CreateState(Session session)
|
||||
{
|
||||
var document = new SessionStateDocument(session.Board.BoardState);
|
||||
|
||||
using var connection = new SqlConnection(this.connectionString);
|
||||
await connection.ExecuteAsync(
|
||||
"session.CreateState",
|
||||
new
|
||||
{
|
||||
SessionId = session.Id.ToString(),
|
||||
Document = JsonSerializer.Serialize(document)
|
||||
},
|
||||
commandType: CommandType.StoredProcedure);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user