-
Notifications
You must be signed in to change notification settings - Fork 2.8k
/
Copy pathContentBaseSave.cs
56 lines (47 loc) · 1.95 KB
/
ContentBaseSave.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
using System.ComponentModel.DataAnnotations;
using System.Runtime.Serialization;
using Umbraco.Cms.Core.Models.Editors;
namespace Umbraco.Cms.Core.Models.ContentEditing;
/// <summary>
/// A model representing a content item to be saved
/// </summary>
[DataContract(Name = "content", Namespace = "")]
public abstract class ContentBaseSave<TPersisted> : ContentItemBasic<ContentPropertyBasic>, IContentSave<TPersisted>
where TPersisted : IContentBase
{
#region IContentSave
/// <inheritdoc />
[DataMember(Name = "action", IsRequired = true)]
[Required]
public ContentSaveAction Action { get; set; }
[DataMember(Name = "properties")]
public override IEnumerable<ContentPropertyBasic> Properties
{
get => base.Properties;
set => base.Properties = value;
}
// These need explicit implementation because we are using internal models
/// <inheritdoc />
[IgnoreDataMember]
TPersisted IContentSave<TPersisted>.PersistedContent { get; set; } = default!;
// Non explicit internal getter so we don't need to explicitly cast in our own code
[IgnoreDataMember]
public TPersisted PersistedContent
{
get => ((IContentSave<TPersisted>)this).PersistedContent;
set => ((IContentSave<TPersisted>)this).PersistedContent = value;
}
/// <summary>
/// The property DTO object is used to gather all required property data including data type information etc... for use
/// with validation - used during inbound model binding
/// </summary>
/// <remarks>
/// We basically use this object to hydrate all required data from the database into one object so we can validate
/// everything we need
/// instead of having to look up all the data individually.
/// This is not used for outgoing model information.
/// </remarks>
[IgnoreDataMember]
public ContentPropertyCollectionDto? PropertyCollectionDto { get; set; }
#endregion
}