using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

namespace Database.Models
{
    public class Package : BaseEntity
    {
        [Required]
        [MaxLength(200)]
        public string Title { get; set; } = string.Empty;
        
        [Required]
        [MaxLength(50)]
        public string Version { get; set; } = string.Empty;
        
        public string? Description { get; set; }
        
        public int ProjectId { get; set; }
        
        public int? SourceBuildId { get; set; }
        
        [Required]
        [MaxLength(50)]
        public string Status { get; set; } = "Draft"; // Draft, Ready, Publishing, Published, Failed
        
        public DateTime? PublishDate { get; set; }
        
        // Navigation properties
        [ForeignKey(nameof(ProjectId))]
        public Project Project { get; set; } = null!;
        
        [ForeignKey(nameof(SourceBuildId))]
        public Build? SourceBuild { get; set; }
        
        public PackageConfiguration? Configuration { get; set; }
        
        public ICollection<Publication> Publications { get; set; } = new List<Publication>();
        
        // Helper properties
        public bool IsPublished => Status == "Published" && PublishDate.HasValue;
        
        public bool IsReadyToPublish => Status == "Ready" && SourceBuildId.HasValue;
    }
}