diff --git a/Nexpo/Models/Notification.cs b/Nexpo/Models/Notification.cs index 713ef99..4f52c38 100644 --- a/Nexpo/Models/Notification.cs +++ b/Nexpo/Models/Notification.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Text.Json.Serialization; namespace Nexpo.Models { @@ -10,6 +11,7 @@ public class Notification public DateTime? ScheduledTime { get; set; } public NotificationType NotificationType { get; set; } public int? EventId { get; set; } + [JsonIgnore] public ICollection UserNotifications { get; set; } } } \ No newline at end of file diff --git a/Nexpo/Models/User.cs b/Nexpo/Models/User.cs index c02f6a2..669a143 100644 --- a/Nexpo/Models/User.cs +++ b/Nexpo/Models/User.cs @@ -38,6 +38,7 @@ public class User public string profilePictureUrl { get; set; } + [JsonIgnore] public ICollection UserNotifications { get; set; } public Guid Uuid { get; set; } = Guid.NewGuid(); public string ExpoPushToken { get; set; } diff --git a/Nexpo/Models/UserNotification.cs b/Nexpo/Models/UserNotification.cs index 0a76a71..e66f8f1 100644 --- a/Nexpo/Models/UserNotification.cs +++ b/Nexpo/Models/UserNotification.cs @@ -1,10 +1,17 @@ +using System.Text.Json.Serialization; + namespace Nexpo.Models { public class UserNotification { public int UserId { get; set; } + + [JsonIgnore] public User User { get; set; } + public int NotificationId { get; set; } + + [JsonIgnore] public Notification Notification { get; set; } } } \ No newline at end of file diff --git a/Nexpo/Startup.cs b/Nexpo/Startup.cs index 7d4ea15..a94fb08 100644 --- a/Nexpo/Startup.cs +++ b/Nexpo/Startup.cs @@ -38,14 +38,7 @@ public Startup(IConfiguration configuration, IWebHostEnvironment environment) public void ConfigureServices(IServiceCollection services) { - services.AddControllers() - .AddJsonOptions(options => - { - // Traps for circular references of json - options.JsonSerializerOptions.ReferenceHandler = System.Text.Json.Serialization.ReferenceHandler.Preserve; - options.JsonSerializerOptions.DefaultIgnoreCondition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingNull; - options.JsonSerializerOptions.MaxDepth = 64; - }); + services.AddControllers(); services.AddRouting(options => {