basic manager layout & re-design model
This commit is contained in:
54
OwnChar/Manager/CharacterManager.cs
Normal file
54
OwnChar/Manager/CharacterManager.cs
Normal file
@@ -0,0 +1,54 @@
|
||||
using OwnChar.Model;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace OwnChar.Manager
|
||||
{
|
||||
public class CharacterManager(OwnCharManager manager)
|
||||
{
|
||||
public OwnCharManager Manager { get; } = manager;
|
||||
|
||||
/// <summary>
|
||||
/// Gets personal characters.
|
||||
/// </summary>
|
||||
/// <param name="group"></param>
|
||||
/// <returns>Returns a collection with personal characters.</returns>
|
||||
public IEnumerable<Character>? GetCharacters()
|
||||
{
|
||||
if (!IsLoggedIn || UserProfile == null)
|
||||
return null;
|
||||
|
||||
return GetCharacters(UserProfile.Group);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets all public ore accessable (e.g. via shares) characters from the specified group.
|
||||
/// </summary>
|
||||
/// <param name="group"></param>
|
||||
/// <returns>Returns a collection with characters for the specified group.</returns>
|
||||
public IEnumerable<Character> GetCharacters(Group group)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Saves a character. If it doesn't exists, it will be created.
|
||||
/// </summary>
|
||||
/// <param name="character">The caracter to save.</param>
|
||||
/// <returns><see cref="true"/> if success, otherwise <see cref="false"/>.</returns>
|
||||
public bool SaveCharacter(Character character)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Deletes a given character. If it doesn't exists, it will be ignored.
|
||||
/// </summary>
|
||||
/// <param name="character"></param>
|
||||
/// <returns><see cref="true"/> if the given character has been deleted successfully or doesn't exist, otherwise <see cref="false"/>.</returns>
|
||||
public bool DeleteCharacter(Character character)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
50
OwnChar/Manager/GroupsManager.cs
Normal file
50
OwnChar/Manager/GroupsManager.cs
Normal file
@@ -0,0 +1,50 @@
|
||||
using OwnChar.Model;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace OwnChar.Manager
|
||||
{
|
||||
public class GroupsManager(OwnCharManager manager)
|
||||
{
|
||||
public OwnCharManager Manager { get; } = manager;
|
||||
|
||||
public Group? GetGroup()
|
||||
{
|
||||
if (!IsLoggedIn || UserProfile == null)
|
||||
return null;
|
||||
|
||||
// ...
|
||||
}
|
||||
|
||||
public IEnumerable<Group>? GetGroups()
|
||||
{
|
||||
if (!IsLoggedIn || UserProfile == null)
|
||||
return null;
|
||||
|
||||
return GetGroups(UserProfile);
|
||||
}
|
||||
|
||||
public IEnumerable<Group>? GetGroups(UserProfile profile)
|
||||
{
|
||||
if (!IsLoggedIn)
|
||||
return null;
|
||||
|
||||
// ...
|
||||
}
|
||||
|
||||
public Group? CreateGroup(UserProfile owner)
|
||||
{
|
||||
}
|
||||
|
||||
public bool SaveGroup(Group group)
|
||||
{
|
||||
}
|
||||
|
||||
public bool DeleteGroup(Group group)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,13 +1,38 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using OwnChar.Data;
|
||||
using OwnChar.Model;
|
||||
using Pilz.Cryptography;
|
||||
|
||||
namespace OwnChar.Manager
|
||||
{
|
||||
public class OwnCharManager
|
||||
{
|
||||
// User
|
||||
public bool IsLoggedIn { get; set; }
|
||||
public UserAccount? CurrentUser { get; set; }
|
||||
|
||||
// Data Provider
|
||||
public IDataProvider DataProvider { get; set; }
|
||||
|
||||
// Manager
|
||||
public UserManager Users { get; }
|
||||
public GroupsManager Groups { get; }
|
||||
public CharacterManager Characters { get; }
|
||||
|
||||
public OwnCharManager(IDataProvider dataProvider)
|
||||
{
|
||||
DataProvider = dataProvider;
|
||||
Users = new(this);
|
||||
Groups = new(this);
|
||||
Characters = new(this);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tries to login on the server.
|
||||
/// </summary>
|
||||
/// <returns>Returns <see cref="true"/> if the login was successfull and <see cref="false"/> if not.</returns>
|
||||
public bool Login(string username, SecureString password)
|
||||
{
|
||||
return IsLoggedIn = true; // TODO: Change `true` to the real check.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
52
OwnChar/Manager/UserManager.cs
Normal file
52
OwnChar/Manager/UserManager.cs
Normal file
@@ -0,0 +1,52 @@
|
||||
using OwnChar.Model;
|
||||
using Pilz.Cryptography;
|
||||
|
||||
namespace OwnChar.Manager
|
||||
{
|
||||
public class UserManager(OwnCharManager manager)
|
||||
{
|
||||
public OwnCharManager Manager { get; } = manager;
|
||||
|
||||
public UserAccount? CreateAccount(string username, SecureString password, string email, string displayName)
|
||||
{
|
||||
// Create account
|
||||
// ...
|
||||
|
||||
// Create profile
|
||||
// ...
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Saves the current logged in user account.
|
||||
/// </summary>
|
||||
/// <returns><see cref="true"/> if success, otherwise <see cref="false"/>.</returns>
|
||||
public bool SaveAccount()
|
||||
{
|
||||
}
|
||||
|
||||
public bool DeleteAccount()
|
||||
{
|
||||
}
|
||||
|
||||
public UserProfile? CreateProfile()
|
||||
{
|
||||
// Create profile
|
||||
// ...
|
||||
|
||||
// Create pre-defined group
|
||||
// ...
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Saves the current logged in user profile.
|
||||
/// </summary>
|
||||
/// <returns><see cref="true"/> if success, otherwise <see cref="false"/>.</returns>
|
||||
public bool SaveProfile()
|
||||
{
|
||||
}
|
||||
|
||||
public bool DeleteProfile()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user