using LCU.Library.Internal.DocumentIngestorModels.Enums; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; namespace LCU.Library.Internal.DocumentIngestorModels.Entities; public class OwnerOverrideInfo : IValidatableObject { public OwnerOverrideInfo() { } public OwnerOverrideInfo(string userName, string entityId, EntityTypes entityType, int documentProcessingInfoId) { UserName = userName; EntityId = entityId; EntityType = entityType; DocumentProcessingInfoId = documentProcessingInfoId; } public int OwnerOverrideInfoId { get; set; } public string UserName { get; set; } public string EntityId { get; set; } public EntityTypes EntityType { get; set; } public int DocumentProcessingInfoId { get; set; } public IEnumerable Validate(ValidationContext validationContext) { if (EntityType == EntityTypes.Unknown && !string.IsNullOrWhiteSpace(EntityId)) { yield return new ValidationResult("Cannot assign EntityType of 'Unknown' and assign EntityId."); } if (EntityType != EntityTypes.Unknown && string.IsNullOrWhiteSpace(EntityId)) { yield return new ValidationResult("There must be an EntityId if EntityType is not 'Unknown'."); } if (string.IsNullOrWhiteSpace(UserName)) { yield return new ValidationResult("UserName cannot be null."); } if (DocumentProcessingInfoId <= 0) { yield return new ValidationResult("DocumentProcessingInfoId must be greater than 0."); } } }