diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Contents/Content.cs b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Contents/Content.cs index e2d4a2a4ac..434ae4847b 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Contents/Content.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Contents/Content.cs @@ -8,12 +8,16 @@ namespace Volo.CmsKit.Contents { public class Content : FullAuditedAggregateRoot, IMultiTenant { + [CanBeNull] public virtual Guid? TenantId { get; protected set; } + [NotNull] public virtual string EntityType { get; protected set; } - public virtual string EntityId { get; set; } + [NotNull] + public virtual string EntityId { get; protected set; } + [NotNull] public virtual string Value { get; protected set; } protected Content() @@ -23,16 +27,22 @@ namespace Volo.CmsKit.Contents public Content(Guid id, [NotNull] string entityType, [NotNull] string entityId, [NotNull] string value, Guid? tenantId = null) : base(id) { - EntityType = Check.NotNullOrWhiteSpace(entityType, nameof(entityType), ContentConsts.MaxEntityTypeLength); EntityId = Check.NotNullOrWhiteSpace(entityId, nameof(entityId), ContentConsts.MaxEntityIdLength); - SetValue(value); + EntityType = Check.NotNullOrEmpty(entityType, nameof(entityType), ContentConsts.MaxEntityTypeLength); + Value = Check.NotNullOrEmpty(value, nameof(value), ContentConsts.MaxValueLength); TenantId = tenantId; } public void SetValue([NotNull] string value) { - Value = Check.NotNullOrWhiteSpace(value, nameof(value), ContentConsts.MaxValueLength); + Value = Check.NotNullOrEmpty(value, nameof(value), ContentConsts.MaxValueLength); + } + + public void SetEntity([NotNull] string entityType, [NotNull] string entityId) + { + EntityType = Check.NotNullOrEmpty(entityType, nameof(entityType), ContentConsts.MaxEntityTypeLength); + EntityId = Check.NotNullOrWhiteSpace(entityId, nameof(entityId), ContentConsts.MaxEntityIdLength); } } }