From bed83e085c266873da39732cc1bb17e168d7f050 Mon Sep 17 00:00:00 2001 From: ijungleboy Date: Mon, 22 Nov 2021 17:45:01 +0100 Subject: [PATCH] Mark some data as ReadOnly in APIs https://github.com/2sic/2sxc/issues/2599 --- ToSic.Eav.WebApi/Dto/ContentTypeDto.cs | 8 +++++++- ToSic.Eav.WebApi/Dto/ContentTypeFieldDto.cs | 5 ++++- ToSic.Eav.WebApi/Dto/IReadOnlyDto.cs | 16 ++++++++++++++++ 3 files changed, 27 insertions(+), 2 deletions(-) create mode 100644 ToSic.Eav.WebApi/Dto/IReadOnlyDto.cs diff --git a/ToSic.Eav.WebApi/Dto/ContentTypeDto.cs b/ToSic.Eav.WebApi/Dto/ContentTypeDto.cs index dfa35aed1..fa368e247 100644 --- a/ToSic.Eav.WebApi/Dto/ContentTypeDto.cs +++ b/ToSic.Eav.WebApi/Dto/ContentTypeDto.cs @@ -1,9 +1,10 @@ using System.Collections.Generic; +using Newtonsoft.Json; using ToSic.Eav.WebApi.Security; namespace ToSic.Eav.WebApi.Dto { - public class ContentTypeDto: IdNameDto + public class ContentTypeDto: IdNameDto, IReadOnlyDto { public string Label { get; set; } public string StaticName { get; set; } @@ -17,5 +18,10 @@ public class ContentTypeDto: IdNameDto public IDictionary Properties { get; set; } public HasPermissionsDto Permissions { get; set; } + + //[JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public bool? IsReadOnly { get; set; } + + public string IsReadOnlyReason { get; set; } } } \ No newline at end of file diff --git a/ToSic.Eav.WebApi/Dto/ContentTypeFieldDto.cs b/ToSic.Eav.WebApi/Dto/ContentTypeFieldDto.cs index e819bc1fc..18610cc65 100644 --- a/ToSic.Eav.WebApi/Dto/ContentTypeFieldDto.cs +++ b/ToSic.Eav.WebApi/Dto/ContentTypeFieldDto.cs @@ -5,7 +5,7 @@ namespace ToSic.Eav.WebApi.Dto { - public class ContentTypeFieldDto + public class ContentTypeFieldDto: IReadOnlyDto { public int Id { get; set; } public int SortOrder { get; set; } @@ -34,5 +34,8 @@ public class ContentTypeFieldDto /// New in v12.01 /// public bool HasFormulas { get; set; } + + public bool? IsReadOnly { get; set; } + public string IsReadOnlyReason { get; set; } } } diff --git a/ToSic.Eav.WebApi/Dto/IReadOnlyDto.cs b/ToSic.Eav.WebApi/Dto/IReadOnlyDto.cs new file mode 100644 index 000000000..c6f704d2b --- /dev/null +++ b/ToSic.Eav.WebApi/Dto/IReadOnlyDto.cs @@ -0,0 +1,16 @@ +using Newtonsoft.Json; + +namespace ToSic.Eav.WebApi.Dto +{ + /// + /// Extends common DTOs to inform about it being read-only, and why + /// + public interface IReadOnlyDto + { + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + bool? IsReadOnly { get; set; } + + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + string IsReadOnlyReason { get; set; } + } +}