25 lines
919 B
C#
25 lines
919 B
C#
using System.Data;
|
|
using Dapper;
|
|
|
|
namespace PlotLine.Data;
|
|
|
|
public interface IToolbarPreferenceRepository
|
|
{
|
|
Task<string?> GetAsync(int userId);
|
|
Task SaveAsync(int userId, string? commandKeysJson);
|
|
}
|
|
|
|
public sealed class ToolbarPreferenceRepository(ISqlConnectionFactory connections) : IToolbarPreferenceRepository
|
|
{
|
|
public async Task<string?> GetAsync(int userId)
|
|
{
|
|
using var connection = connections.CreateConnection();
|
|
return await connection.QuerySingleOrDefaultAsync<string>("dbo.UserToolbar_Get", new { UserID = userId }, commandType: CommandType.StoredProcedure);
|
|
}
|
|
public async Task SaveAsync(int userId, string? commandKeysJson)
|
|
{
|
|
using var connection = connections.CreateConnection();
|
|
await connection.ExecuteAsync("dbo.UserToolbar_Save", new { UserID = userId, CommandKeysJson = commandKeysJson }, commandType: CommandType.StoredProcedure);
|
|
}
|
|
}
|