Added Customer, Contact and Address with Service
Labeled all service to enable assembly scanning
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
namespace LiteCharms.Features.MidrandBooks.Customers.Entities;
|
||||
|
||||
[EntityTypeConfiguration<AddressConfiguration, Address>]
|
||||
public class Address : Models.Address
|
||||
{
|
||||
public virtual Customer? Customer { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
namespace LiteCharms.Features.MidrandBooks.Customers.Entities;
|
||||
|
||||
public class AddressConfiguration : IEntityTypeConfiguration<Address>
|
||||
{
|
||||
public void Configure(EntityTypeBuilder<Address> builder)
|
||||
{
|
||||
builder.ToTable("Addresses");
|
||||
|
||||
builder.HasKey(a => a.Id);
|
||||
builder.Property(a => a.CustomerId).IsRequired();
|
||||
builder.Property(a => a.CreatedAt).IsRequired().ValueGeneratedOnAdd().HasDefaultValueSql("now()");
|
||||
builder.Property(a => a.UpdatedAt).HasDefaultValueSql("now()");
|
||||
builder.Property(a => a.Name).IsRequired();
|
||||
builder.Property(a => a.Type).IsRequired();
|
||||
builder.Property(a => a.BuildingType).IsRequired();
|
||||
builder.Property(a => a.Street).IsRequired();
|
||||
builder.Property(a => a.City).IsRequired();
|
||||
builder.Property(a => a.State).IsRequired();
|
||||
builder.Property(a => a.PostalCode).IsRequired();
|
||||
builder.Property(a => a.Country).IsRequired();
|
||||
builder.Property(a => a.IsPrimary).HasDefaultValue(false);
|
||||
builder.Property(a => a.Enabled).HasDefaultValue(true);
|
||||
|
||||
builder.HasOne(a => a.Customer)
|
||||
.WithMany(c => c.Addresses)
|
||||
.HasForeignKey(a => a.CustomerId)
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
namespace LiteCharms.Features.MidrandBooks.Customers.Entities;
|
||||
|
||||
[EntityTypeConfiguration<ContactConfiguration, Contact>]
|
||||
public class Contact : Models.Contact
|
||||
{
|
||||
public virtual Customer? Customer { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
namespace LiteCharms.Features.MidrandBooks.Customers.Entities;
|
||||
|
||||
public class ContactConfiguration : IEntityTypeConfiguration<Contact>
|
||||
{
|
||||
public void Configure(EntityTypeBuilder<Contact> builder)
|
||||
{
|
||||
builder.ToTable("Contacts");
|
||||
|
||||
builder.HasKey(c => c.Id);
|
||||
builder.Property(c => c.CustomerId).IsRequired();
|
||||
builder.Property(c => c.CreatedAt).IsRequired().ValueGeneratedOnAdd().HasDefaultValueSql("now()");
|
||||
builder.Property(c => c.UpdatedAt).HasDefaultValueSql("now()");
|
||||
builder.Property(c => c.Name).IsRequired();
|
||||
builder.Property(c => c.LastName).IsRequired();
|
||||
builder.Property(c => c.Type).IsRequired();
|
||||
builder.Property(c => c.Phone).IsRequired();
|
||||
builder.Property(c => c.Email).IsRequired();
|
||||
builder.Property(c => c.IsPrimary).HasDefaultValue(false);
|
||||
builder.Property(c => c.Enabled).HasDefaultValue(true);
|
||||
|
||||
builder.HasOne(c => c.Customer)
|
||||
.WithMany(c => c.Contacts)
|
||||
.HasForeignKey(c => c.CustomerId)
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
namespace LiteCharms.Features.MidrandBooks.Customers.Entities;
|
||||
|
||||
[EntityTypeConfiguration<CustomerConfiguration, Customer>]
|
||||
public class Customer : Models.Customer
|
||||
{
|
||||
public virtual ICollection<Contact> Contacts { get; set; } = [];
|
||||
|
||||
public virtual ICollection<Address> Addresses { get; set; } = [];
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
namespace LiteCharms.Features.MidrandBooks.Customers.Entities;
|
||||
|
||||
public class CustomerConfiguration : IEntityTypeConfiguration<Customer>
|
||||
{
|
||||
public void Configure(EntityTypeBuilder<Customer> builder)
|
||||
{
|
||||
builder.ToTable("Customers");
|
||||
|
||||
builder.HasKey(c => c.Id);
|
||||
builder.Property(c => c.CreatedAt).IsRequired().ValueGeneratedOnAdd().HasDefaultValueSql("now()");
|
||||
builder.Property(c => c.UpdatedAt).HasDefaultValueSql("now()");
|
||||
builder.Property(c => c.Company).IsRequired(false);
|
||||
builder.Property(c => c.VatNumber).IsRequired(false);
|
||||
builder.Property(c => c.Email).IsRequired();
|
||||
builder.Property(c => c.Phone).IsRequired();
|
||||
builder.Property(c => c.Website).IsRequired();
|
||||
builder.Property(c => c.SocialMedia).IsRequired(false).HasColumnType("jsonb");
|
||||
builder.Property(c => c.Enabled).HasDefaultValue(true);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user