Add server configuration service and repo

This commit is contained in:
Holden
2026-06-18 13:43:59 -05:00
parent 7fc7e1dc91
commit 608def3ac8
15 changed files with 272 additions and 9 deletions

View File

@@ -0,0 +1,24 @@
using RecNet.Domain.Exceptions;
namespace RecNet.Domain.Entities.Configuration;
public class ServerConfig
{
private ServerConfig(string key, string value)
{
Key = RequireValue(key, nameof(key));
Value = value;
}
public string Key { get; private set; }
public string Value { get; private set; }
public static ServerConfig Create(string key, string value)
=> new(key, value);
public void SetValue(string value)
=> Value = value;
private static string RequireValue(string value, string parameterName)
=> !string.IsNullOrWhiteSpace(value) ? value : throw new DomainException($"{parameterName} is required.");
}

View File

@@ -6,8 +6,4 @@
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<Folder Include="Entities\" />
</ItemGroup>
</Project>

View File

@@ -0,0 +1,10 @@
using RecNet.Domain.Entities.Configuration;
namespace RecNet.Domain.Repositories;
public interface IServerConfigRepository
{
Task<ServerConfig?> GetAsync(string key, CancellationToken ct = default);
Task SetAsync(string key, string value, CancellationToken ct = default);
Task SaveChangesAsync(CancellationToken ct = default);
}