diff --git a/Endpoint/Common/Model/Admin.cs b/Endpoint/Common/Model/Admin.cs deleted file mode 100644 index 59e4b60..0000000 --- a/Endpoint/Common/Model/Admin.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace Mirea.Api.Endpoint.Common.Model; - -public class Admin -{ - public const string PathToSave = "admin.json"; - public required string Username { get; set; } - public required string Email { get; set; } - public required string PasswordHash { get; set; } - public required string Salt { get; set; } -} \ No newline at end of file diff --git a/Endpoint/Common/Settings/Admin.cs b/Endpoint/Common/Settings/Admin.cs new file mode 100644 index 0000000..0e41c36 --- /dev/null +++ b/Endpoint/Common/Settings/Admin.cs @@ -0,0 +1,25 @@ +using Mirea.Api.Endpoint.Common.Services; +using System.IO; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Mirea.Api.Endpoint.Common.Settings; + +public class Admin : ISaveSettings +{ + [JsonIgnore] private const string FileName = "admin.json"; + + [JsonIgnore] + public static string FilePath => PathBuilder.Combine(FileName); + + public required string Username { get; set; } + public required string Email { get; set; } + public required string PasswordHash { get; set; } + public required string Salt { get; set; } + + + public void SaveSetting() + { + File.WriteAllText(FilePath, JsonSerializer.Serialize(this)); + } +} \ No newline at end of file