2020-01-20 15:20:21 +01:00
|
|
|
|
using System.Collections.Generic;
|
2018-07-19 19:32:07 +10:00
|
|
|
|
using System.ComponentModel.DataAnnotations;
|
2018-06-29 19:52:40 +02:00
|
|
|
|
using System.Runtime.Serialization;
|
2021-02-18 11:06:02 +01:00
|
|
|
|
using Umbraco.Cms.Core.Models.Editors;
|
2018-06-29 19:52:40 +02:00
|
|
|
|
|
2021-02-18 11:06:02 +01:00
|
|
|
|
namespace Umbraco.Cms.Core.Models.ContentEditing
|
2018-06-29 19:52:40 +02:00
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// A model representing a content item to be saved
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
[DataContract(Name = "content", Namespace = "")]
|
2018-07-19 19:32:07 +10:00
|
|
|
|
public class ContentItemSave : IContentSave<IContent>
|
2018-04-04 01:59:51 +10:00
|
|
|
|
{
|
2020-06-15 23:05:32 +10:00
|
|
|
|
public ContentItemSave()
|
2018-07-19 19:32:07 +10:00
|
|
|
|
{
|
|
|
|
|
|
UploadedFiles = new List<ContentPropertyFile>();
|
|
|
|
|
|
Variants = new List<ContentVariantSave>();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[DataMember(Name = "id", IsRequired = true)]
|
|
|
|
|
|
[Required]
|
|
|
|
|
|
public int Id { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
[DataMember(Name = "parentId", IsRequired = true)]
|
|
|
|
|
|
[Required]
|
|
|
|
|
|
public int ParentId { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
[DataMember(Name = "variants", IsRequired = true)]
|
|
|
|
|
|
public IEnumerable<ContentVariantSave> Variants { get; set; }
|
2020-01-20 15:20:21 +01:00
|
|
|
|
|
2018-07-19 19:32:07 +10:00
|
|
|
|
[DataMember(Name = "contentTypeAlias", IsRequired = true)]
|
|
|
|
|
|
[Required(AllowEmptyStrings = false)]
|
2022-01-21 11:43:58 +01:00
|
|
|
|
public string? ContentTypeAlias { get; set; }
|
2018-04-10 01:38:35 +10:00
|
|
|
|
|
2018-06-29 19:52:40 +02:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// The template alias to save
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
[DataMember(Name = "templateAlias")]
|
2022-01-21 11:43:58 +01:00
|
|
|
|
public string? TemplateAlias { get; set; }
|
2020-01-20 15:20:21 +01:00
|
|
|
|
|
2018-07-19 19:32:07 +10:00
|
|
|
|
#region IContentSave
|
|
|
|
|
|
|
|
|
|
|
|
[DataMember(Name = "action", IsRequired = true)]
|
|
|
|
|
|
[Required]
|
|
|
|
|
|
public ContentSaveAction Action { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
[IgnoreDataMember]
|
|
|
|
|
|
public List<ContentPropertyFile> UploadedFiles { get; }
|
|
|
|
|
|
|
|
|
|
|
|
//These need explicit implementation because we are using internal models
|
|
|
|
|
|
/// <inheritdoc />
|
|
|
|
|
|
[IgnoreDataMember]
|
2022-01-21 11:43:58 +01:00
|
|
|
|
IContent? IContentSave<IContent>.PersistedContent { get; set; }
|
2020-01-20 15:20:21 +01:00
|
|
|
|
|
2018-07-19 19:32:07 +10:00
|
|
|
|
//Non explicit internal getter so we don't need to explicitly cast in our own code
|
|
|
|
|
|
[IgnoreDataMember]
|
2022-01-21 11:43:58 +01:00
|
|
|
|
public IContent? PersistedContent
|
2018-07-19 19:32:07 +10:00
|
|
|
|
{
|
|
|
|
|
|
get => ((IContentSave<IContent>)this).PersistedContent;
|
|
|
|
|
|
set => ((IContentSave<IContent>)this).PersistedContent = value;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
2018-06-29 19:52:40 +02:00
|
|
|
|
}
|
|
|
|
|
|
}
|