1
0
mirror of https://github.com/RaidMax/IW4M-Admin.git synced 2025-06-10 15:20:48 -05:00

continue rework of profile

start moving profile info out of javascript into componentview
rework meta data to include count and offset
This commit is contained in:
RaidMax
2019-03-27 19:40:26 -05:00
parent 4f77625889
commit 25472b06c3
17 changed files with 277 additions and 250 deletions

View File

@ -11,7 +11,7 @@ namespace SharedLibraryCore.Services
{
public class MetaService
{
private static List<Func<int, Task<List<ProfileMeta>>>> _metaActions = new List<Func<int, Task<List<ProfileMeta>>>>();
private static List<Func<int, int, int, Task<List<ProfileMeta>>>> _metaActions = new List<Func<int, int, int, Task<List<ProfileMeta>>>>();
/// <summary>
/// adds or updates meta key and value to the database
@ -71,7 +71,7 @@ namespace SharedLibraryCore.Services
/// aads a meta task to the runtime meta list
/// </summary>
/// <param name="metaAction"></param>
public static void AddRuntimeMeta(Func<int, Task<List<ProfileMeta>>> metaAction)
public static void AddRuntimeMeta(Func<int, int, int, Task<List<ProfileMeta>>> metaAction)
{
_metaActions.Add(metaAction);
}
@ -80,14 +80,16 @@ namespace SharedLibraryCore.Services
/// retrieves all the runtime meta information for given client idea
/// </summary>
/// <param name="clientId">id of the client</param>
/// <param name="count">number of meta items to retrieve</param>
/// <param name="offset">offset from the first item</param>
/// <returns></returns>
public static async Task<List<ProfileMeta>> GetRuntimeMeta(int clientId)
public static async Task<List<ProfileMeta>> GetRuntimeMeta(int clientId, int offset = 0, int count = int.MaxValue)
{
var meta = new List<ProfileMeta>();
foreach (var action in _metaActions)
{
meta.AddRange(await action(clientId));
meta.AddRange(await action(clientId, offset, count));
}
return meta;

View File

@ -195,7 +195,7 @@ namespace SharedLibraryCore.Services
PunisherName = punisherAlias.Name,
PunisherId = penalty.PunisherId,
Offense = penalty.Offense,
Type = penalty.Type.ToString(),
PenaltyType = penalty.Type.ToString(),
TimeRemaining = penalty.Expires.HasValue ? (now > penalty.Expires ? "" : penalty.Expires.ToString()) : DateTime.MaxValue.ToString(),
AutomatedOffense = penalty.AutomatedOffense,
Expired = penalty.Expires.HasValue && penalty.Expires <= DateTime.UtcNow
@ -208,9 +208,9 @@ namespace SharedLibraryCore.Services
list.ForEach(p =>
{
// todo: why does this have to be done?
if (((PenaltyInfo)p.Value).Type.Length < 2)
if (((PenaltyInfo)p.Value).PenaltyType.Length < 2)
{
((PenaltyInfo)p.Value).Type = ((Penalty.PenaltyType)Convert.ToInt32(((PenaltyInfo)p.Value).Type)).ToString();
((PenaltyInfo)p.Value).PenaltyType = ((Penalty.PenaltyType)Convert.ToInt32(((PenaltyInfo)p.Value).PenaltyType)).ToString();
}
var pi = ((PenaltyInfo)p.Value);
@ -251,7 +251,7 @@ namespace SharedLibraryCore.Services
PunisherName = punisherAlias.Name,
PunisherId = penalty.PunisherId,
Offense = penalty.Offense,
Type = penalty.Type.ToString(),
PenaltyType = penalty.Type.ToString(),
AutomatedOffense = penalty.AutomatedOffense
},
When = penalty.When,
@ -263,9 +263,9 @@ namespace SharedLibraryCore.Services
list.ForEach(p =>
{
// todo: why does this have to be done?
if (((PenaltyInfo)p.Value).Type.Length < 2)
if (((PenaltyInfo)p.Value).PenaltyType.Length < 2)
{
((PenaltyInfo)p.Value).Type = ((Penalty.PenaltyType)Convert.ToInt32(((PenaltyInfo)p.Value).Type)).ToString();
((PenaltyInfo)p.Value).PenaltyType = ((Penalty.PenaltyType)Convert.ToInt32(((PenaltyInfo)p.Value).PenaltyType)).ToString();
}
});