diff --git a/Server/Data/CustomerData.cs b/Server/Data/CustomerData.cs
index 538810f..426f5fc 100644
--- a/Server/Data/CustomerData.cs
+++ b/Server/Data/CustomerData.cs
@@ -14,11 +14,18 @@ namespace Server.Data
#endregion
- #region Private Properties
+
+ ///
+ /// Retrieves the file path for the settings JSON file.
+ ///
+ /// The file path of the settings JSON file as a string.
+ private static string GetFilePath()
+ {
+ var parentDirectory = Directory.GetParent(Directory.GetCurrentDirectory());
+ if (parentDirectory == null) return "Customers.json";
- private static string FileName => "Customers.json";
-
- #endregion
+ return Path.Combine(parentDirectory.FullName, "Customers.json");
+ }
#region Public Method LoadAsync
@@ -30,8 +37,8 @@ namespace Server.Data
///
public static async Task LoadAsync()
{
- if (!File.Exists(FileName)) return;
- var jsonString = await File.ReadAllTextAsync(FileName);
+ if (!File.Exists(GetFilePath())) return;
+ var jsonString = await File.ReadAllTextAsync(GetFilePath());
var deserialized = JsonSerializer.Deserialize(jsonString)!;
Instance = deserialized;
@@ -50,7 +57,7 @@ namespace Server.Data
public static async Task SaveAsync()
{
var jsonString = JsonSerializer.Serialize(Instance, new JsonSerializerOptions { WriteIndented = true, DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull });
- await File.WriteAllTextAsync(FileName, jsonString);
+ await File.WriteAllTextAsync(GetFilePath(), jsonString);
}
#endregion
diff --git a/Server/Data/SettingsData.cs b/Server/Data/SettingsData.cs
index e0c52ae..dddccb3 100644
--- a/Server/Data/SettingsData.cs
+++ b/Server/Data/SettingsData.cs
@@ -18,12 +18,19 @@ namespace Server.Data
#endregion
- #region Private Properties
- private static string FileName => "Settings.json";
-
- #endregion
+ ///
+ /// Retrieves the file path for the settings JSON file.
+ ///
+ /// The file path of the settings JSON file as a string.
+ private static string GetFilePath()
+ {
+ var parentDirectory = Directory.GetParent(Directory.GetCurrentDirectory());
+ if (parentDirectory == null) return "Settings.json";
+ return Path.Combine(parentDirectory.FullName, "Settings.json");
+ }
+
#region Public Method Load
///
@@ -32,8 +39,9 @@ namespace Server.Data
/// A task that represents the asynchronous load operation.
public static async Task LoadAsync()
{
- if (!File.Exists(FileName)) return;
- var jsonString = await File.ReadAllTextAsync(FileName);
+
+ if (!File.Exists(GetFilePath())) return;
+ var jsonString = await File.ReadAllTextAsync(GetFilePath());
var deserialized = JsonSerializer.Deserialize(jsonString)!;
Instance = deserialized;
@@ -50,7 +58,7 @@ namespace Server.Data
public static async Task SaveAsync()
{
var jsonString = JsonSerializer.Serialize(Instance, new JsonSerializerOptions { WriteIndented = true, DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull});
- await File.WriteAllTextAsync(FileName, jsonString);
+ await File.WriteAllTextAsync(GetFilePath(), jsonString);
}
#endregion