added json ignore tags because oc cyclic references in Logs

This commit is contained in:
Sarah Faey 2022-11-24 19:08:07 +01:00
parent fc5e75cc9d
commit f322c18c57
3 changed files with 8 additions and 6 deletions

View file

@ -1,4 +1,6 @@
namespace Lieb.Models.GuildWars2.Raid using System.Text.Json.Serialization;
namespace Lieb.Models.GuildWars2.Raid
{ {
public class DiscordRaidMessage public class DiscordRaidMessage
{ {
@ -6,6 +8,7 @@
public int RaidId { get; set; } public int RaidId { get; set; }
[JsonIgnore(Condition = JsonIgnoreCondition.Always)]
public Raid Raid { get; set; } public Raid Raid { get; set; }
public ulong DiscordMessageId { get; set; } public ulong DiscordMessageId { get; set; }

View file

@ -1,5 +1,6 @@
using System.Text.Json; using System.Text.Json;
using System.Text.Json.Serialization;
namespace Lieb.Models.GuildWars2.Raid namespace Lieb.Models.GuildWars2.Raid
{ {
@ -28,14 +29,13 @@ namespace Lieb.Models.GuildWars2.Raid
public LiebUser User {get; set;} public LiebUser User {get; set;}
[JsonIgnore(Condition = JsonIgnoreCondition.Always)]
public Raid? Raid { get; set; } public Raid? Raid { get; set; }
public RaidTemplate? RaidTemplate { get; set; } public RaidTemplate? RaidTemplate { get; set; }
public static RaidLog CreateRaidLog(ulong userId, Raid raid) public static RaidLog CreateRaidLog(ulong userId, Raid raid)
{ {
raid.RaidLogs.Clear();
raid.Reminders.Clear();
return new RaidLog() return new RaidLog()
{ {
Type = LogType.Raid, Type = LogType.Raid,
@ -61,8 +61,6 @@ namespace Lieb.Models.GuildWars2.Raid
public static RaidLog CreateRaidTemplateLog(ulong userId, RaidTemplate template) public static RaidLog CreateRaidTemplateLog(ulong userId, RaidTemplate template)
{ {
template.TemplateLogs.Clear();
template.Reminders.Clear();
return new RaidLog() return new RaidLog()
{ {
Type = LogType.RaidTemplate, Type = LogType.RaidTemplate,

View file

@ -1,5 +1,5 @@
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using System; using System.Text.Json.Serialization;
namespace Lieb.Models.GuildWars2.Raid namespace Lieb.Models.GuildWars2.Raid
{ {
@ -42,6 +42,7 @@ namespace Lieb.Models.GuildWars2.Raid
public int RaidId { get; set; } public int RaidId { get; set; }
[JsonIgnore(Condition = JsonIgnoreCondition.Always)]
public Raid Raid { get; set; } public Raid Raid { get; set; }
} }