using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; using Novelly.Api.Beats; using Novelly.Api.Common; using Novelly.Api.Novels; using Novelly.Api.Tags; namespace Novelly.Api.Chapters; public class Chapter { public Guid Id { get; set; } = Guid.NewGuid(); public Guid NovelId { get; set; } public Novel? Novel { get; set; } public int Number { get; set; } public string Title { get; set; } = string.Empty; public string? Summary { get; set; } public string? Setting { get; set; } public string? Notes { get; set; } public DraftStatus Status { get; set; } = DraftStatus.Planned; public int? TargetWordCount { get; set; } public string? Prose { get; set; } public int WordCount { get; set; } public DateTimeOffset CreatedAt { get; set; } = DateTimeOffset.UtcNow; public DateTimeOffset UpdatedAt { get; set; } = DateTimeOffset.UtcNow; public List Beats { get; set; } = []; public List Tags { get; set; } = []; } public class ChapterEntityTypeConfiguration : IEntityTypeConfiguration { public void Configure(EntityTypeBuilder entity) { entity.Property(c => c.Title).IsRequired().HasMaxLength(300); entity.Property(c => c.Status).HasConversion().HasMaxLength(32); entity.HasIndex(c => new { c.NovelId, c.Number }); } }