diff --git a/OwnChar/Data/IDataManager.cs b/OwnChar/Data/IDataManager.cs index 16f8819..1013d01 100644 --- a/OwnChar/Data/IDataManager.cs +++ b/OwnChar/Data/IDataManager.cs @@ -16,4 +16,8 @@ public interface IDataManager // Group management abstract UserProfile? GetOwner(Group group); abstract IEnumerable? GetMembers(Group group); + + // Character management + abstract IEnumerable? GetCharacters(Group group); + abstract IEnumerable? GetCharacters(UserProfile profile); } diff --git a/OwnChar/Data/IDataProvider.cs b/OwnChar/Data/IDataProvider.cs index cc501fd..01716fa 100644 --- a/OwnChar/Data/IDataProvider.cs +++ b/OwnChar/Data/IDataProvider.cs @@ -26,4 +26,6 @@ public interface IDataProvider abstract IEnumerable? GetGroupMembers(Group group); abstract UserProfile? GetOwner(Group group); abstract UserProfile? GetOwner(Character character); + abstract IEnumerable? GetCharacters(Group group); + abstract IEnumerable? GetCharacters(UserProfile jprofile); } diff --git a/OwnChar/Data/Managers/DefaultDataManager.cs b/OwnChar/Data/Managers/DefaultDataManager.cs index 8c30a4b..d172b60 100644 --- a/OwnChar/Data/Managers/DefaultDataManager.cs +++ b/OwnChar/Data/Managers/DefaultDataManager.cs @@ -87,4 +87,14 @@ public class DefaultDataManager : IDataManager DataProvider.Delete(account); return true; } + + public IEnumerable? GetCharacters(Group group) + { + return DataProvider.GetCharacters(group); + } + + public IEnumerable? GetCharacters(UserProfile profile) + { + return DataProvider.GetCharacters(profile); + } } diff --git a/OwnChar/Data/Providers/JsonFile/JsonFileDataProvider.cs b/OwnChar/Data/Providers/JsonFile/JsonFileDataProvider.cs index 0f4865f..7608e8e 100644 --- a/OwnChar/Data/Providers/JsonFile/JsonFileDataProvider.cs +++ b/OwnChar/Data/Providers/JsonFile/JsonFileDataProvider.cs @@ -221,4 +221,18 @@ public class JsonFileDataProvider : IDataProvider return jcharacter.Owner; return null; } + + public IEnumerable? GetCharacters(Group group) + { + if (group is JsonGroup jgroup) + return jgroup.Characters; + return null; + } + + public IEnumerable? GetCharacters(UserProfile profile) + { + if (profile is UserProfile jprofile) + return JsonFile.Characters.Where(n => n.Owner == profile); + return null; + } } diff --git a/OwnChar/Manager/CharacterManager.cs b/OwnChar/Manager/CharacterManager.cs index 2c05234..501bdd9 100644 --- a/OwnChar/Manager/CharacterManager.cs +++ b/OwnChar/Manager/CharacterManager.cs @@ -8,11 +8,21 @@ public class CharacterManager(OwnCharManager manager) public IEnumerable? GetCharacters(Group? group) { - throw new NotImplementedException(); + Manager.CheckLogin(); + + if (group != null) + return Manager.DataManager?.GetCharacters(group); + + return null; } public IEnumerable? GetCharacters(UserProfile? profile) { - throw new NotImplementedException(); + Manager.CheckLogin(); + + if (profile != null) + return Manager.DataManager?.GetCharacters(profile); + + return null; } }