From f15d725a937329a5b28367502fd6dff22a8dbd19 Mon Sep 17 00:00:00 2001 From: Ruidy Nemausat Date: Fri, 28 Feb 2020 13:42:23 +0100 Subject: [PATCH] JSonIgnore M2M joint --- Models/Project.cs | 9 ++++++--- README.md | 3 +-- Startup.cs | 7 ------- 3 files changed, 7 insertions(+), 12 deletions(-) diff --git a/Models/Project.cs b/Models/Project.cs index cf32255..8236c98 100644 --- a/Models/Project.cs +++ b/Models/Project.cs @@ -2,7 +2,7 @@ using System; using System.Collections.Generic; using System.Linq; using System.ComponentModel.DataAnnotations; -using TicketManager.DTO; +using System.Text.Json.Serialization; namespace TicketManager.Models { @@ -20,11 +20,13 @@ namespace TicketManager.Models public string Description { get; set; } [DataType(DataType.Date)] - [DisplayFormat(DataFormatString = "{0:yyyy-MM-dd}", ApplyFormatInEditMode = false)] + [DisplayFormat(DataFormatString = "{0:yyyy-MM-dd}", + ApplyFormatInEditMode = false)] public DateTime CreationDate { get; private set; } = DateTime.Now; [DataType(DataType.Date)] - [DisplayFormat(DataFormatString = "{0:yyyy-MM-dd}", ApplyFormatInEditMode = true)] + [DisplayFormat(DataFormatString = "{0:yyyy-MM-dd}", + ApplyFormatInEditMode = true)] public DateTime EndingDate { get; set; } [Display(Name = "Progress")] @@ -45,6 +47,7 @@ namespace TicketManager.Models [Display(Name = "Project Manager")] public AppUser Manager { get; set; } + [JsonIgnore] public List Assignments { get; set; } = new List(); public List Tickets { get; set; } = new List(); diff --git a/README.md b/README.md index 416e763..7f0589e 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,6 @@ - `React` client on the front-end (TypeScript) - [Materialize](https://materializecss.com) CSS librairy for styling -- API: Newtonsoft.Json, to avoid cycle errors - Hosting: ? - Authentication : [Auth0](https://auth0.com/) - Analytics : Google Analytics & Mixpanel @@ -48,5 +47,5 @@ - [ ] error page redirect when offline. - [ ] ticket/files/activities list placeholders when empty - [ ] think about public/private DTO's constructor, getters and setters -- [x] write dtos without circular dependencies +- [X] write dtos without circular dependencies. - [ ] use dtoRequest for PutProjects diff --git a/Startup.cs b/Startup.cs index 4b0df45..0783c3b 100644 --- a/Startup.cs +++ b/Startup.cs @@ -12,9 +12,7 @@ using Microsoft.Extensions.Logging; using Microsoft.AspNetCore.SpaServices.ReactDevelopmentServer; using Microsoft.EntityFrameworkCore; using Microsoft.OpenApi.Models; -using Microsoft.AspNetCore.Mvc.NewtonsoftJson; using Microsoft.AspNetCore.Authentication.JwtBearer; -// using Newtonsoft.Json; using TicketManager.Data; [assembly: ApiController] @@ -49,11 +47,6 @@ namespace TicketManager }); services.AddControllers(); - // .AddNewtonsoftJson(options => - // { - // options.SerializerSettings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore; // avoid cycle ref errors - // } - // ); services.AddSpaStaticFiles(configuration => {