Created Author, Book, AuthorBook, Page and Product with Price

This commit is contained in:
Khwezi Mngoma
2026-05-25 22:18:53 +02:00
parent 87da491ed6
commit d55bf4f82f
39 changed files with 1383 additions and 23 deletions
@@ -0,0 +1,9 @@
using LiteCharms.Features.MidrandBooks.AuthorBooks.Entities;
namespace LiteCharms.Features.MidrandBooks.Pages.Entities;
[EntityTypeConfiguration<BookPageConfiguration, BookPage>]
public class BookPage : Models.BookPage
{
public virtual AuthorBook Book { get; set; } = new();
}
@@ -0,0 +1,26 @@
namespace LiteCharms.Features.MidrandBooks.Pages.Entities;
public class BookPageConfiguration : IEntityTypeConfiguration<BookPage>
{
public void Configure(EntityTypeBuilder<BookPage> builder)
{
builder.ToTable("BookPages");
builder.HasKey(bp => bp.Id);
builder.Property(bp => bp.CreatedAt).IsRequired().ValueGeneratedOnAdd().HasDefaultValueSql("now()");
builder.Property(bp => bp.UpdatedAt).HasDefaultValueSql("now()");
builder.Property(bp => bp.Number).IsRequired().HasDefaultValue(0);
builder.Property(bp => bp.AuthorBookId).IsRequired();
builder.Property(bp => bp.Content).IsRequired();
builder.Property(bp => bp.Type).IsRequired();
builder.Property(bp => bp.ContentType).IsRequired();
builder.Property(bp => bp.Notes).IsRequired(false).HasColumnType("jsonb");
builder.Property(bp => bp.References).IsRequired(false).HasColumnType("jsonb");
builder.Property(bp => bp.Enabled).HasDefaultValue(true);
builder.HasOne(f =>f.Book)
.WithMany(b => b.Pages)
.HasForeignKey(f => f.AuthorBookId)
.OnDelete(DeleteBehavior.NoAction);
}
}