Compare commits
1 Commits
5055540f76
...
dab404d95e
| Author | SHA1 | Date | |
|---|---|---|---|
| dab404d95e |
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using OwnChar.Model;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
@@ -8,5 +9,44 @@ namespace OwnChar.Data
|
||||
{
|
||||
public class ClientServerDataProvider : IDataProvider
|
||||
{
|
||||
public bool Save(Character character)
|
||||
{
|
||||
}
|
||||
|
||||
public bool Save(UserProfile profile)
|
||||
{
|
||||
}
|
||||
|
||||
public bool Save(UserAccount account)
|
||||
{
|
||||
}
|
||||
|
||||
public bool Save(Group group)
|
||||
{
|
||||
}
|
||||
|
||||
public bool Save(PropertyCategory category)
|
||||
{
|
||||
}
|
||||
|
||||
public bool Delete(Character character)
|
||||
{
|
||||
}
|
||||
|
||||
public bool Delete(UserProfile profile)
|
||||
{
|
||||
}
|
||||
|
||||
public bool Delete(UserAccount account)
|
||||
{
|
||||
}
|
||||
|
||||
public bool Delete(Group group)
|
||||
{
|
||||
}
|
||||
|
||||
public bool Delete(PropertyCategory category)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,11 @@
|
||||
namespace OwnChar.Model
|
||||
{
|
||||
public class Character
|
||||
public class Character(Group group, string name)
|
||||
{
|
||||
public ulong Id { get; set; }
|
||||
public PropertyList Properties { get; set; } = [];
|
||||
public string Name { get; set; } = name;
|
||||
public Group Group { get; set; } = group;
|
||||
public List<Property> Properties { get; set; } = [];
|
||||
public List<PropertyCategory> PropertyCategories { get; set; } = [];
|
||||
}
|
||||
}
|
||||
|
||||
15
OwnChar/Model/Group.cs
Normal file
15
OwnChar/Model/Group.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace OwnChar.Model
|
||||
{
|
||||
public class Group(UserProfile owner)
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public UserProfile Owner { get; set; } = owner;
|
||||
public List<UserProfile> Members { get; set; } = [];
|
||||
}
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
namespace OwnChar.Model
|
||||
{
|
||||
public class PropertyList : List<Property>
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -1,17 +1,17 @@
|
||||
using Pilz.Cryptography;
|
||||
|
||||
namespace OwnChar.Model
|
||||
namespace OwnChar.Model
|
||||
{
|
||||
public class UserAccount(string email, string username, SecureString password, string? displayName)
|
||||
public class UserAccount
|
||||
{
|
||||
public ulong Id { get; set; }
|
||||
public UserProfile Profile { get; set; } = new(string.IsNullOrWhiteSpace(displayName) ? username : displayName);
|
||||
public string Username { get; set; } = username;
|
||||
public string Email { get; set; } = email;
|
||||
public SecureString Password { get; set; } = password;
|
||||
public string Username { get; set; }
|
||||
public string Email { get; set; }
|
||||
public string Password { get; set; }
|
||||
|
||||
public UserAccount(string email, string username, SecureString password) : this(email, username, password, username)
|
||||
internal UserAccount(string email, string username, string password)
|
||||
{
|
||||
Username = username;
|
||||
Email = email;
|
||||
Password = password;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,5 +4,6 @@
|
||||
{
|
||||
public ulong Id { get; set; }
|
||||
public string Name { get; set; } = name;
|
||||
public UserAccount? Account { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user