Compare commits
1 Commits
2e9acf1578
...
444bc0b44f
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
444bc0b44f |
@@ -2,16 +2,16 @@
|
|||||||
|
|
||||||
public static class DataManagerActions
|
public static class DataManagerActions
|
||||||
{
|
{
|
||||||
public static DataManagerAction Create { get; } = new("create");
|
public static DataManagerAction Get { get; } = new("create");
|
||||||
public static DataManagerAction Save { get; } = new("save");
|
public static DataManagerAction Save { get; } = new("save");
|
||||||
public static DataManagerAction Delete { get; } = new("delete");
|
public static DataManagerAction Delete { get; } = new("delete");
|
||||||
public static DataManagerAction Associate { get; } = new("associate");
|
public static DataManagerAction Associate { get; } = new("associate");
|
||||||
|
|
||||||
public static class Creation
|
public static class Getter
|
||||||
{
|
{
|
||||||
public static DataManagerAction UserAccount { get; } = new(Create, "useraccount");
|
public static DataManagerAction UserAccount { get; } = new(Get, "useraccount");
|
||||||
public static DataManagerAction Group { get; } = new(Create, "group");
|
public static DataManagerAction Group { get; } = new(Get, "group");
|
||||||
public static DataManagerAction Character { get; } = new(Create, "character");
|
public static DataManagerAction Character { get; } = new(Get, "character");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Association
|
public static class Association
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
using OwnChar.Api;
|
using OwnChar.Api;
|
||||||
using OwnChar.Model;
|
using OwnChar.Model;
|
||||||
using static System.Runtime.InteropServices.JavaScript.JSType;
|
|
||||||
|
|
||||||
namespace OwnChar.Data.Managers;
|
namespace OwnChar.Data.Managers;
|
||||||
|
|
||||||
@@ -42,35 +41,49 @@ public class DefaultDataManager : IDataManager
|
|||||||
|
|
||||||
protected virtual bool HandleCreate(OnActionEventArgs e)
|
protected virtual bool HandleCreate(OnActionEventArgs e)
|
||||||
{
|
{
|
||||||
if (e.Action != DataManagerActions.Create)
|
if (e.Action != DataManagerActions.Get)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Character
|
// Character
|
||||||
if (e.Action == DataManagerActions.Creation.Character)
|
if (e.Action == DataManagerActions.Getter.Character)
|
||||||
|
{
|
||||||
|
if (e.ActionType == DataManagerActionType.Set)
|
||||||
{
|
{
|
||||||
if (e.Object is not Group group || e.Parameters.Length < 1 || e.Parameters[0] is not string name)
|
if (e.Object is not Group group || e.Parameters.Length < 1 || e.Parameters[0] is not string name)
|
||||||
return false;
|
return false;
|
||||||
e.Result = CreateCharacter(e.CurrentUser, name, group);
|
e.Result = CreateCharacter(e.CurrentUser, name, group);
|
||||||
return e.Result != null;
|
return e.Result != null;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Group
|
// Group
|
||||||
if (e.Action == DataManagerActions.Creation.Group)
|
if (e.Action == DataManagerActions.Getter.Group)
|
||||||
|
{
|
||||||
|
if (e.ActionType == DataManagerActionType.Get)
|
||||||
{
|
{
|
||||||
if (e.Parameters.Length < 1 || e.Parameters[0] is not string name)
|
if (e.Parameters.Length < 1 || e.Parameters[0] is not string name)
|
||||||
return false;
|
return false;
|
||||||
e.Result = CreateGroup(e.CurrentUser, name);
|
e.Result = CreateGroup(e.CurrentUser, name);
|
||||||
return e.Result != null;
|
return e.Result != null;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// User
|
// User
|
||||||
if (e.Action == DataManagerActions.Creation.UserAccount)
|
if (e.Action == DataManagerActions.Getter.UserAccount)
|
||||||
|
{
|
||||||
|
if (e.ActionType == DataManagerActionType.Get)
|
||||||
{
|
{
|
||||||
if (e.Parameters.Length < 2 || e.Parameters[0] is not string username || e.Parameters[1] is not string password)
|
if (e.Parameters.Length < 2 || e.Parameters[0] is not string username || e.Parameters[1] is not string password)
|
||||||
return false;
|
return false;
|
||||||
e.Result = CreateUserAccount(username, password);
|
e.Result = CreateUserAccount(username, password);
|
||||||
return e.Result != null;
|
return e.Result != null;
|
||||||
}
|
}
|
||||||
|
//else
|
||||||
|
//{
|
||||||
|
// e.Result = DataProvider.GetUserAccounts();
|
||||||
|
// return e.Result != null;
|
||||||
|
//}
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
using OwnChar.Api;
|
using OwnChar.Api;
|
||||||
using OwnChar.Data;
|
using OwnChar.Data;
|
||||||
using OwnChar.Model;
|
using OwnChar.Model;
|
||||||
using static System.Runtime.InteropServices.JavaScript.JSType;
|
|
||||||
|
|
||||||
namespace OwnChar.Manager.Modules;
|
namespace OwnChar.Manager.Modules;
|
||||||
|
|
||||||
@@ -41,7 +40,7 @@ public class GroupsManager(OwnCharManager manager) : OwnCharManagerModule(manage
|
|||||||
{
|
{
|
||||||
ArgumentException.ThrowIfNullOrWhiteSpace(name, nameof(name));
|
ArgumentException.ThrowIfNullOrWhiteSpace(name, nameof(name));
|
||||||
Manager.CheckLogin();
|
Manager.CheckLogin();
|
||||||
return Manager.DataManager.ExecuteAction(DataManagerActions.Creation.Group, DataManagerActionType.Default, Manager.CurrentUser, null, name).Result as Group;
|
return Manager.DataManager.ExecuteAction(DataManagerActions.Getter.Group, DataManagerActionType.Set, Manager.CurrentUser, null, name).Result as Group;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool DeleteGroup(Group? group)
|
public bool DeleteGroup(Group? group)
|
||||||
|
|||||||
Reference in New Issue
Block a user