This commit is contained in:
2025-09-08 23:07:25 +04:30
parent 33dd1f781b
commit d858a5ad77
26 changed files with 624 additions and 16 deletions
@@ -0,0 +1,28 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using VizhTalk.Learning.Domain.Entities;
namespace VizhTalk.Learning.Infrastructure.EF.Configurations
{
internal class CourseConfiguration : IEntityTypeConfiguration<Course>
{
public void Configure(EntityTypeBuilder<Course> builder)
{
builder.ToTable(name: nameof(Course), Schema.Learning);
builder.HasKey(x => x.Id);
builder.Property(x => x.Id)
.ValueGeneratedOnAdd()
.HasConversion(x => x.Value, x => new Domain.TypeIds.CourseId(x));
builder.Property(x => x.Title)
.HasConversion(x => x.Value, x => new(x));
}
}
}
@@ -0,0 +1,245 @@
// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using VizhTalk.Learning.Infrastructure.EF;
#nullable disable
namespace VizhTalk.Learning.Infrastructure.Migrations
{
[DbContext(typeof(LearningDbContext))]
[Migration("20250907192005_Course")]
partial class Course
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasDefaultSchema("Learning")
.HasAnnotation("ProductVersion", "8.0.19")
.HasAnnotation("Relational:MaxIdentifierLength", 128);
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
modelBuilder.Entity("VizhTalk.Learning.Domain.Entities.Course", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<long>("Id"));
b.Property<DateTime>("CreateOn")
.HasColumnType("datetime2");
b.Property<Guid>("ImageId")
.HasColumnType("uniqueidentifier");
b.Property<bool>("IsActive")
.HasColumnType("bit");
b.Property<bool>("IsDeleted")
.HasColumnType("bit");
b.Property<short?>("LanguageId")
.HasColumnType("smallint");
b.Property<DateTime>("LastUpdate")
.HasColumnType("datetime2");
b.Property<int>("Order")
.HasColumnType("int");
b.Property<string>("Title")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.HasIndex("ImageId");
b.HasIndex("LanguageId");
b.ToTable("Courses", "Learning");
});
modelBuilder.Entity("VizhTalk.Learning.Domain.Entities.FileGroup", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<long>("Id"));
b.Property<DateTime>("CreateOn")
.HasColumnType("datetime2");
b.Property<bool>("IsActive")
.HasColumnType("bit");
b.Property<bool>("IsDeleted")
.HasColumnType("bit");
b.Property<bool>("IsSecure")
.HasColumnType("bit");
b.Property<string>("Key")
.IsRequired()
.HasMaxLength(150)
.HasColumnType("nvarchar(150)")
.HasColumnName("Key");
b.Property<DateTime>("LastUpdate")
.HasColumnType("datetime2");
b.Property<long>("MediaGroupId")
.HasColumnType("bigint");
b.Property<string>("Title")
.IsRequired()
.HasColumnType("nvarchar(max)")
.HasColumnName("Title");
b.HasKey("Id");
b.ToTable("FileGroups", "Attachment");
});
modelBuilder.Entity("VizhTalk.Learning.Domain.Entities.Language", b =>
{
b.Property<short>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("smallint");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<short>("Id"));
b.Property<DateTime>("CreateOn")
.HasColumnType("datetime2");
b.Property<Guid>("IconId")
.HasColumnType("uniqueidentifier");
b.Property<bool>("IsActive")
.HasColumnType("bit");
b.Property<bool>("IsDeleted")
.HasColumnType("bit");
b.Property<DateTime>("LastUpdate")
.HasColumnType("datetime2");
b.Property<string>("Title")
.IsRequired()
.HasMaxLength(60)
.HasColumnType("nvarchar(60)");
b.HasKey("Id");
b.HasIndex("IconId");
b.ToTable("Languages", "Learning");
});
modelBuilder.Entity("VizhTalk.Learning.Domain.Entities.Media", b =>
{
b.Property<Guid>("Id")
.HasColumnType("uniqueidentifier");
b.Property<string>("ContentType")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<DateTime>("CreateOn")
.HasColumnType("datetime2");
b.Property<bool>("IsActive")
.HasColumnType("bit");
b.Property<bool>("IsDeleted")
.HasColumnType("bit");
b.Property<DateTime>("LastUpdate")
.HasColumnType("datetime2");
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(150)
.HasColumnType("nvarchar(150)");
b.Property<int>("Size")
.HasColumnType("int");
b.HasKey("Id");
b.ToTable("Medias", "Learning");
});
modelBuilder.Entity("VizhTalk.Learning.Domain.Entities.Course", b =>
{
b.HasOne("VizhTalk.Learning.Domain.Entities.Media", "Image")
.WithMany()
.HasForeignKey("ImageId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("VizhTalk.Learning.Domain.Entities.Language", null)
.WithMany("Courses")
.HasForeignKey("LanguageId");
b.Navigation("Image");
});
modelBuilder.Entity("VizhTalk.Learning.Domain.Entities.Language", b =>
{
b.HasOne("VizhTalk.Learning.Domain.Entities.Media", "Icon")
.WithMany()
.HasForeignKey("IconId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Icon");
});
modelBuilder.Entity("VizhTalk.Learning.Domain.Entities.Media", b =>
{
b.OwnsOne("VizhTalk.Learning.Domain.ValueObjects.EntityType", "EntityType", b1 =>
{
b1.Property<Guid>("MediaId")
.HasColumnType("uniqueidentifier");
b1.Property<string>("EntityId")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("nvarchar(50)")
.HasColumnName("EntityId");
b1.Property<int>("Type")
.HasMaxLength(200)
.HasColumnType("int")
.HasColumnName("EntityType");
b1.HasKey("MediaId");
b1.ToTable("Medias", "Learning");
b1.WithOwner()
.HasForeignKey("MediaId");
});
b.Navigation("EntityType")
.IsRequired();
});
modelBuilder.Entity("VizhTalk.Learning.Domain.Entities.Language", b =>
{
b.Navigation("Courses");
});
#pragma warning restore 612, 618
}
}
}
@@ -0,0 +1,69 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace VizhTalk.Learning.Infrastructure.Migrations
{
/// <inheritdoc />
public partial class Course : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Courses",
schema: "Learning",
columns: table => new
{
Id = table.Column<long>(type: "bigint", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Title = table.Column<string>(type: "nvarchar(max)", nullable: false),
ImageId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
Order = table.Column<int>(type: "int", nullable: false),
LanguageId = table.Column<short>(type: "smallint", nullable: true),
IsDeleted = table.Column<bool>(type: "bit", nullable: false),
IsActive = table.Column<bool>(type: "bit", nullable: false),
CreateOn = table.Column<DateTime>(type: "datetime2", nullable: false),
LastUpdate = table.Column<DateTime>(type: "datetime2", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Courses", x => x.Id);
table.ForeignKey(
name: "FK_Courses_Languages_LanguageId",
column: x => x.LanguageId,
principalSchema: "Learning",
principalTable: "Languages",
principalColumn: "Id");
table.ForeignKey(
name: "FK_Courses_Medias_ImageId",
column: x => x.ImageId,
principalSchema: "Learning",
principalTable: "Medias",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_Courses_ImageId",
schema: "Learning",
table: "Courses",
column: "ImageId");
migrationBuilder.CreateIndex(
name: "IX_Courses_LanguageId",
schema: "Learning",
table: "Courses",
column: "LanguageId");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Courses",
schema: "Learning");
}
}
}
@@ -23,6 +23,48 @@ namespace VizhTalk.Learning.Infrastructure.Migrations
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
modelBuilder.Entity("VizhTalk.Learning.Domain.Entities.Course", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<long>("Id"));
b.Property<DateTime>("CreateOn")
.HasColumnType("datetime2");
b.Property<Guid>("ImageId")
.HasColumnType("uniqueidentifier");
b.Property<bool>("IsActive")
.HasColumnType("bit");
b.Property<bool>("IsDeleted")
.HasColumnType("bit");
b.Property<short?>("LanguageId")
.HasColumnType("smallint");
b.Property<DateTime>("LastUpdate")
.HasColumnType("datetime2");
b.Property<int>("Order")
.HasColumnType("int");
b.Property<string>("Title")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.HasIndex("ImageId");
b.HasIndex("LanguageId");
b.ToTable("Courses", "Learning");
});
modelBuilder.Entity("VizhTalk.Learning.Domain.Entities.FileGroup", b =>
{
b.Property<long>("Id")
@@ -134,6 +176,21 @@ namespace VizhTalk.Learning.Infrastructure.Migrations
b.ToTable("Medias", "Learning");
});
modelBuilder.Entity("VizhTalk.Learning.Domain.Entities.Course", b =>
{
b.HasOne("VizhTalk.Learning.Domain.Entities.Media", "Image")
.WithMany()
.HasForeignKey("ImageId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("VizhTalk.Learning.Domain.Entities.Language", null)
.WithMany("Courses")
.HasForeignKey("LanguageId");
b.Navigation("Image");
});
modelBuilder.Entity("VizhTalk.Learning.Domain.Entities.Language", b =>
{
b.HasOne("VizhTalk.Learning.Domain.Entities.Media", "Icon")
@@ -174,6 +231,11 @@ namespace VizhTalk.Learning.Infrastructure.Migrations
b.Navigation("EntityType")
.IsRequired();
});
modelBuilder.Entity("VizhTalk.Learning.Domain.Entities.Language", b =>
{
b.Navigation("Courses");
});
#pragma warning restore 612, 618
}
}