using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.Runtime.Serialization; using Newtonsoft.Json; using Umbraco.Core.Models; using Umbraco.Core.Models.Validation; using Umbraco.Web.WebApi; namespace Umbraco.Web.Models.ContentEditing { /// /// A model representing a basic content item /// [DataContract(Name = "content", Namespace = "")] public class ContentItemBasic : EntityBasic { [DataMember(Name = "updateDate")] public DateTime UpdateDate { get; set; } [DataMember(Name = "createDate")] public DateTime CreateDate { get; set; } [DataMember(Name = "owner")] public UserBasic Owner { get; set; } [DataMember(Name = "updator")] public UserBasic Updator { get; set; } [DataMember(Name = "contentTypeAlias", IsRequired = true)] [Required(AllowEmptyStrings = false)] public string ContentTypeAlias { get; set; } [DataMember(Name = "sortOrder")] public int SortOrder { get; set; } protected bool Equals(ContentItemBasic other) { return Id == other.Id; } public override bool Equals(object obj) { if (ReferenceEquals(null, obj)) return false; if (ReferenceEquals(this, obj)) return true; var other = obj as ContentItemBasic; return other != null && Equals(other); } public override int GetHashCode() { return Id; } } /// /// A model representing a basic content item with properties /// [DataContract(Name = "content", Namespace = "")] public class ContentItemBasic : ContentItemBasic where T : ContentPropertyBasic where TPersisted : IContentBase { public ContentItemBasic() { //ensure its not null _properties = new List(); } private IEnumerable _properties; [DataMember(Name = "properties")] public virtual IEnumerable Properties { get { return _properties; } set { _properties = value; } } /// /// The real persisted content object /// [JsonIgnore] internal TPersisted PersistedContent { get; set; } /// /// The DTO object used to gather all required content data including data type information etc... for use with validation /// /// /// 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. /// [JsonIgnore] internal ContentItemDto ContentDto { get; set; } } }