Commit 804e6ccf authored by hasan khaddour's avatar hasan khaddour

fix s.

parent 1ae9e12a
......@@ -18,21 +18,12 @@ namespace PSManagement.Infrastructure.Persistence
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.ApplyConfigurationsFromAssembly(typeof(AppDbContext).Assembly);
base.OnModelCreating(modelBuilder);
modelBuilder.HasAnnotation("Relational:Collation", "Arabic_CI_AS");
modelBuilder.Entity<Customer>(builder =>
{
builder.OwnsOne(c => c.Address);
});
modelBuilder.Entity<Customer>(builder =>
{
builder.OwnsMany(c => c.ContactInfo, contactInfoBuilder =>
{
contactInfoBuilder.OwnsOne(c => c.MobileNumber);
contactInfoBuilder.OwnsOne(c => c.PhoneNumber);
});
});
}
......
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using PSManagement.Domain.Customers.Aggregate;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace PSManagement.Infrastructure.Persistence.EntitiesConfiguration
{
public class CustomerEntityConfiguration : IEntityTypeConfiguration<Customer>
{
public void Configure(EntityTypeBuilder<Customer> builder)
{
builder.OwnsOne(c => c.Address, address =>
{
address.Property(a => a.StreetName).HasColumnName("StreetName");
address.Property(a => a.City).HasColumnName("City");
address.Property(a => a.StreetNumber).HasColumnName("StreetNumber");
address.Property(a => a.ZipCode).HasColumnName("ZipCode");
}
);
builder.OwnsMany(c => c.ContactInfo);
}
}
}
// <auto-generated />
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using PSManagement.Infrastructure.Persistence;
namespace PSManagement.Infrastructure.Persistence.Migrations
{
[DbContext(typeof(AppDbContext))]
[Migration("20240728124023_AddCustomer2")]
partial class AddCustomer2
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("Relational:Collation", "Arabic_CI_AS")
.HasAnnotation("Relational:MaxIdentifierLength", 128)
.HasAnnotation("ProductVersion", "5.0.17")
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
modelBuilder.Entity("PSManagement.Domain.Customers.Aggregate.Customer", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int")
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
b.Property<string>("CustomerName")
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("Customers");
});
modelBuilder.Entity("PSManagement.Domain.Identity.Aggregate.User", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int")
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
b.Property<string>("Email")
.HasColumnType("nvarchar(max)");
b.Property<string>("FirstName")
.HasColumnType("nvarchar(max)");
b.Property<string>("HashedPassword")
.HasColumnType("nvarchar(max)");
b.Property<string>("LastName")
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("Users");
});
modelBuilder.Entity("PSManagement.Domain.Customers.Aggregate.Customer", b =>
{
b.OwnsMany("PSManagement.Domain.Customers.Entities.ContactInfo", "ContactInfo", b1 =>
{
b1.Property<int>("CustomerId")
.HasColumnType("int");
b1.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int")
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
b1.Property<string>("Email")
.HasColumnType("nvarchar(max)");
b1.HasKey("CustomerId", "Id");
b1.ToTable("ContactInfo");
b1.WithOwner()
.HasForeignKey("CustomerId");
b1.OwnsOne("PSManagement.Domain.Customers.ValueObjects.ContactNumber", "MobileNumber", b2 =>
{
b2.Property<int>("ContactInfoCustomerId")
.HasColumnType("int");
b2.Property<int>("ContactInfoId")
.ValueGeneratedOnAdd()
.HasColumnType("int")
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
b2.Property<int>("Number")
.HasColumnType("int")
.HasColumnName("MobileNumber");
b2.HasKey("ContactInfoCustomerId", "ContactInfoId");
b2.ToTable("ContactInfo");
b2.WithOwner()
.HasForeignKey("ContactInfoCustomerId", "ContactInfoId");
});
b1.OwnsOne("PSManagement.Domain.Customers.ValueObjects.ContactNumber", "PhoneNumber", b2 =>
{
b2.Property<int>("ContactInfoCustomerId")
.HasColumnType("int");
b2.Property<int>("ContactInfoId")
.ValueGeneratedOnAdd()
.HasColumnType("int")
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
b2.Property<int>("Number")
.HasColumnType("int")
.HasColumnName("PhoneNumber");
b2.HasKey("ContactInfoCustomerId", "ContactInfoId");
b2.ToTable("ContactInfo");
b2.WithOwner()
.HasForeignKey("ContactInfoCustomerId", "ContactInfoId");
});
b1.Navigation("MobileNumber");
b1.Navigation("PhoneNumber");
});
b.OwnsOne("PSManagement.Domain.Customers.ValueObjects.Address", "Address", b1 =>
{
b1.Property<int>("CustomerId")
.ValueGeneratedOnAdd()
.HasColumnType("int")
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
b1.Property<string>("City")
.HasColumnType("nvarchar(max)")
.HasColumnName("City");
b1.Property<string>("StreetName")
.HasColumnType("nvarchar(max)")
.HasColumnName("StreetName");
b1.Property<int>("StreetNumber")
.HasColumnType("int")
.HasColumnName("StreetNumber");
b1.Property<int>("ZipCode")
.HasColumnType("int")
.HasColumnName("ZipCode");
b1.HasKey("CustomerId");
b1.ToTable("Customers");
b1.WithOwner()
.HasForeignKey("CustomerId");
});
b.Navigation("Address");
b.Navigation("ContactInfo");
});
#pragma warning restore 612, 618
}
}
}
using Microsoft.EntityFrameworkCore.Migrations;
namespace PSManagement.Infrastructure.Persistence.Migrations
{
public partial class AddCustomer2 : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.RenameColumn(
name: "Address_ZipCode",
table: "Customers",
newName: "ZipCode");
migrationBuilder.RenameColumn(
name: "Address_StreetNumber",
table: "Customers",
newName: "StreetNumber");
migrationBuilder.RenameColumn(
name: "Address_StreetName",
table: "Customers",
newName: "StreetName");
migrationBuilder.RenameColumn(
name: "Address_City",
table: "Customers",
newName: "City");
migrationBuilder.RenameColumn(
name: "PhoneNumber_Number",
table: "ContactInfo",
newName: "PhoneNumber");
migrationBuilder.RenameColumn(
name: "MobileNumber_Number",
table: "ContactInfo",
newName: "MobileNumber");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.RenameColumn(
name: "ZipCode",
table: "Customers",
newName: "Address_ZipCode");
migrationBuilder.RenameColumn(
name: "StreetNumber",
table: "Customers",
newName: "Address_StreetNumber");
migrationBuilder.RenameColumn(
name: "StreetName",
table: "Customers",
newName: "Address_StreetName");
migrationBuilder.RenameColumn(
name: "City",
table: "Customers",
newName: "Address_City");
migrationBuilder.RenameColumn(
name: "PhoneNumber",
table: "ContactInfo",
newName: "PhoneNumber_Number");
migrationBuilder.RenameColumn(
name: "MobileNumber",
table: "ContactInfo",
newName: "MobileNumber_Number");
}
}
}
// <auto-generated />
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using PSManagement.Infrastructure.Persistence;
namespace PSManagement.Infrastructure.Persistence.Migrations
{
[DbContext(typeof(AppDbContext))]
[Migration("20240728142935_AddCustomer3")]
partial class AddCustomer3
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("Relational:Collation", "Arabic_CI_AS")
.HasAnnotation("Relational:MaxIdentifierLength", 128)
.HasAnnotation("ProductVersion", "5.0.17")
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
modelBuilder.Entity("PSManagement.Domain.Customers.Aggregate.Customer", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int")
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
b.Property<string>("CustomerName")
.HasColumnType("nvarchar(max)");
b.Property<string>("Email")
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("Customers");
});
modelBuilder.Entity("PSManagement.Domain.Identity.Aggregate.User", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int")
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
b.Property<string>("Email")
.HasColumnType("nvarchar(max)");
b.Property<string>("FirstName")
.HasColumnType("nvarchar(max)");
b.Property<string>("HashedPassword")
.HasColumnType("nvarchar(max)");
b.Property<string>("LastName")
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("Users");
});
modelBuilder.Entity("PSManagement.Domain.Customers.Aggregate.Customer", b =>
{
b.OwnsMany("PSManagement.Domain.Customers.Entities.ContactInfo", "ContactInfo", b1 =>
{
b1.Property<int>("CustomerId")
.HasColumnType("int");
b1.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int")
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
b1.Property<string>("ConatctValue")
.HasColumnType("nvarchar(max)");
b1.Property<string>("ContactType")
.HasColumnType("nvarchar(max)");
b1.HasKey("CustomerId", "Id");
b1.ToTable("ContactInfo");
b1.WithOwner()
.HasForeignKey("CustomerId");
});
b.OwnsOne("PSManagement.Domain.Customers.ValueObjects.Address", "Address", b1 =>
{
b1.Property<int>("CustomerId")
.ValueGeneratedOnAdd()
.HasColumnType("int")
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
b1.Property<string>("City")
.HasColumnType("nvarchar(max)")
.HasColumnName("City");
b1.Property<string>("StreetName")
.HasColumnType("nvarchar(max)")
.HasColumnName("StreetName");
b1.Property<int>("StreetNumber")
.HasColumnType("int")
.HasColumnName("StreetNumber");
b1.Property<int>("ZipCode")
.HasColumnType("int")
.HasColumnName("ZipCode");
b1.HasKey("CustomerId");
b1.ToTable("Customers");
b1.WithOwner()
.HasForeignKey("CustomerId");
});
b.Navigation("Address");
b.Navigation("ContactInfo");
});
#pragma warning restore 612, 618
}
}
}
using Microsoft.EntityFrameworkCore.Migrations;
namespace PSManagement.Infrastructure.Persistence.Migrations
{
public partial class AddCustomer3 : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "MobileNumber",
table: "ContactInfo");
migrationBuilder.DropColumn(
name: "PhoneNumber",
table: "ContactInfo");
migrationBuilder.RenameColumn(
name: "Email",
table: "ContactInfo",
newName: "ContactType");
migrationBuilder.AddColumn<string>(
name: "Email",
table: "Customers",
type: "nvarchar(max)",
nullable: true);
migrationBuilder.AddColumn<string>(
name: "ConatctValue",
table: "ContactInfo",
type: "nvarchar(max)",
nullable: true);
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "Email",
table: "Customers");
migrationBuilder.DropColumn(
name: "ConatctValue",
table: "ContactInfo");
migrationBuilder.RenameColumn(
name: "ContactType",
table: "ContactInfo",
newName: "Email");
migrationBuilder.AddColumn<int>(
name: "MobileNumber",
table: "ContactInfo",
type: "int",
nullable: true);
migrationBuilder.AddColumn<int>(
name: "PhoneNumber",
table: "ContactInfo",
type: "int",
nullable: true);
}
}
}
......@@ -29,6 +29,9 @@ namespace PSManagement.Infrastructure.Persistence.Migrations
b.Property<string>("CustomerName")
.HasColumnType("nvarchar(max)");
b.Property<string>("Email")
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("Customers");
......@@ -70,7 +73,10 @@ namespace PSManagement.Infrastructure.Persistence.Migrations
.HasColumnType("int")
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
b1.Property<string>("Email")
b1.Property<string>("ConatctValue")
.HasColumnType("nvarchar(max)");
b1.Property<string>("ContactType")
.HasColumnType("nvarchar(max)");
b1.HasKey("CustomerId", "Id");
......@@ -79,52 +85,6 @@ namespace PSManagement.Infrastructure.Persistence.Migrations
b1.WithOwner()
.HasForeignKey("CustomerId");
b1.OwnsOne("PSManagement.Domain.Customers.ValueObjects.ContactNumber", "MobileNumber", b2 =>
{
b2.Property<int>("ContactInfoCustomerId")
.HasColumnType("int");
b2.Property<int>("ContactInfoId")
.ValueGeneratedOnAdd()
.HasColumnType("int")
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
b2.Property<int>("Number")
.HasColumnType("int");
b2.HasKey("ContactInfoCustomerId", "ContactInfoId");
b2.ToTable("ContactInfo");
b2.WithOwner()
.HasForeignKey("ContactInfoCustomerId", "ContactInfoId");
});
b1.OwnsOne("PSManagement.Domain.Customers.ValueObjects.ContactNumber", "PhoneNumber", b2 =>
{
b2.Property<int>("ContactInfoCustomerId")
.HasColumnType("int");
b2.Property<int>("ContactInfoId")
.ValueGeneratedOnAdd()
.HasColumnType("int")
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
b2.Property<int>("Number")
.HasColumnType("int");
b2.HasKey("ContactInfoCustomerId", "ContactInfoId");
b2.ToTable("ContactInfo");
b2.WithOwner()
.HasForeignKey("ContactInfoCustomerId", "ContactInfoId");
});
b1.Navigation("MobileNumber");
b1.Navigation("PhoneNumber");
});
b.OwnsOne("PSManagement.Domain.Customers.ValueObjects.Address", "Address", b1 =>
......@@ -135,16 +95,20 @@ namespace PSManagement.Infrastructure.Persistence.Migrations
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
b1.Property<string>("City")
.HasColumnType("nvarchar(max)");
.HasColumnType("nvarchar(max)")
.HasColumnName("City");
b1.Property<string>("StreetName")
.HasColumnType("nvarchar(max)");
.HasColumnType("nvarchar(max)")
.HasColumnName("StreetName");
b1.Property<int>("StreetNumber")
.HasColumnType("int");
.HasColumnType("int")
.HasColumnName("StreetNumber");
b1.Property<int>("ZipCode")
.HasColumnType("int");
.HasColumnType("int")
.HasColumnName("ZipCode");
b1.HasKey("CustomerId");
......
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<Folder Include="EntitiesConfiguration\" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="5.0.17">
......
......@@ -5,7 +5,7 @@ namespace PSManagement.SharedKernel.Events
{
public interface IDomainEvent : INotification
{
public DateTime DateOccurred { get; set; }
// public DateTime DateOccurred { get; set; }
}
}
using MediatR;
using PSManagement.SharedKernel.Events;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace PSManagement.SharedKernel.DomainEvents
{
public interface IDomainEventHandler<T> :INotificationHandler<T> where T : IDomainEvent
{
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment