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,28 @@
namespace LiteCharms.Features.MidrandBooks.AuthorBooks.Entities;
public class AuthorBookConfiguration : IEntityTypeConfiguration<AuthorBook>
{
public void Configure(EntityTypeBuilder<AuthorBook> builder)
{
builder.ToTable("Books");
builder.HasKey(f => f.AuthorId);
builder.Property(f => f.CreatedAt).IsRequired().ValueGeneratedOnAdd().HasDefaultValueSql("now()");
builder.Property(f => f.UpdatedAt).HasDefaultValueSql("now()");
builder.Property(f => f.AuthorId).IsRequired();
builder.Property(f => f.ProductId).IsRequired();
builder.Property(f => f.Rating).IsRequired(false);
builder.Property(f => f.Ranking).IsRequired(false);
builder.Property(f => f.Enabled).HasDefaultValue(true);
builder.HasOne(f => f.Author)
.WithMany(a => a.Books)
.HasForeignKey(f => f.AuthorId)
.OnDelete(DeleteBehavior.Restrict);
builder.HasOne(f => f.Book)
.WithMany()
.HasForeignKey(f => f.ProductId)
.OnDelete(DeleteBehavior.Restrict);
}
}