diff options
Diffstat (limited to 'docker/crupest-api/CrupestApi/CrupestApi.Commons/Secrets/SecretService.cs')
-rw-r--r-- | docker/crupest-api/CrupestApi/CrupestApi.Commons/Secrets/SecretService.cs | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/docker/crupest-api/CrupestApi/CrupestApi.Commons/Secrets/SecretService.cs b/docker/crupest-api/CrupestApi/CrupestApi.Commons/Secrets/SecretService.cs index 47e9583..69acad3 100644 --- a/docker/crupest-api/CrupestApi/CrupestApi.Commons/Secrets/SecretService.cs +++ b/docker/crupest-api/CrupestApi/CrupestApi.Commons/Secrets/SecretService.cs @@ -1,5 +1,5 @@ +using System.Data; using CrupestApi.Commons.Crud; -using Dapper; namespace CrupestApi.Commons.Secrets; @@ -11,23 +11,26 @@ public class SecretService : CrudService<SecretInfo>, ISecretService } - protected override void DoInitializeDatabase(System.Data.IDbConnection connection) + protected override void DoInitializeDatabase(IDbConnection connection) { base.DoInitializeDatabase(connection); using var transaction = connection.BeginTransaction(); - _table.Insert(connection, new SecretInfo - { - Key = SecretsConstants.SecretManagementKey, - Secret = "crupest", - Description = "This is the init key. Please revoke it immediately after creating a new one." - }); + var insertClause = InsertClause.Create() + .Add(nameof(SecretInfo.Key), SecretsConstants.SecretManagementKey) + .Add(nameof(SecretInfo.Secret), "crupest") + .Add(nameof(SecretInfo.Description), "This is the init key. Please revoke it immediately after creating a new one."); + _table.Insert(connection, insertClause); transaction.Commit(); } public void CreateTestSecret(string key, string secret) { var connection = _dbConnection; - connection.Execute("INSERT INTO secrets (key, secret, description) VALUES (@key, @secret, @desc)", new { key, secret, desc = "Test key." }); + var insertClause = InsertClause.Create() + .Add(nameof(SecretInfo.Key), key) + .Add(nameof(SecretInfo.Secret), secret) + .Add(nameof(SecretInfo.Description), "Test secret."); + _table.Insert(connection, insertClause); } public List<string> GetPermissions(string secret) |