reworked Logging changes

This commit is contained in:
Sarah Faey 2022-11-15 20:23:48 +01:00
parent b8feed971c
commit a504925752
7 changed files with 93 additions and 58 deletions

View file

@ -24,7 +24,7 @@ namespace Lieb.Models.GuildWars2.Raid
public ICollection<RaidSignUp> SignUps { get; set; } = new HashSet<RaidSignUp>();
public ICollection<RaidSignUpHistory> SignUpHistory { get; set; } = new HashSet<RaidSignUpHistory>();
public ICollection<RaidLog> RaidLogs { get; set; } = new HashSet<RaidLog>();
public Raid() { }

View file

@ -0,0 +1,72 @@
using System.Text.Json;
namespace Lieb.Models.GuildWars2.Raid
{
public class RaidLog
{
public enum LogType
{
Raid = 1,
RaidTemplate = 2,
RaidSignUp = 3
}
public int RaidLogId { get; set; }
public LogType Type {get; set;}
public ulong UserId {get; set;}
public int? RaidId { get; set; }
public int? RaidTemplateId { get; set; }
public string LogEntry {get; set;} = string.Empty;
public DateTimeOffset Time { get; set; } = DateTimeOffset.UtcNow;
public LiebUser User {get; set;}
public Raid? Raid { get; set; }
public RaidTemplate? RaidTemplate { get; set; }
public static RaidLog CreateRaidLog(ulong userId, Raid raid)
{
return new RaidLog()
{
Type = LogType.Raid,
UserId = userId,
RaidId = raid.RaidId,
LogEntry = JsonSerializer.Serialize(raid),
Time = DateTimeOffset.UtcNow
};
}
public static RaidLog CreateSignUpLog(ulong userId, RaidSignUp signUp, string signedUpUserName)
{
string message = $"changed Status of {signedUpUserName} to: {signUp.SignUpType.ToString()}";
return new RaidLog()
{
Type = LogType.RaidSignUp,
UserId = userId,
RaidId = signUp.RaidId,
LogEntry = message,
Time = DateTimeOffset.UtcNow
};
}
public static RaidLog CreateRaidTemplateLog(ulong userId, RaidTemplate template)
{
return new RaidLog()
{
Type = LogType.RaidTemplate,
UserId = userId,
RaidTemplateId = template.RaidTemplateId,
LogEntry = JsonSerializer.Serialize(template),
Time = DateTimeOffset.UtcNow
};
}
}
}

View file

@ -1,28 +0,0 @@
namespace Lieb.Models.GuildWars2.Raid
{
public class RaidSignUpHistory
{
public int RaidSignUpHistoryId { get; set; }
public int RaidId { get; set; }
public ulong UserId {get; set;}
public int GuildWars2AccountId { get; set; }
//public ulong SignedUpByUserId {get; set;}
public string UserName {get; set;} = string.Empty;
public DateTimeOffset Time { get; set; } = DateTimeOffset.Now;
public SignUpType SignUpType { get; set; }
public LiebUser User {get; set;}
//public LiebUser SignedUpByUser {get; set;}
public Raid Raid { get; set; }
public GuildWars2Account GuildWars2Account { get; set; }
}
}