first commit

This commit is contained in:
2026-06-03 18:31:41 +03:30
commit 01f87cc461
71 changed files with 10802 additions and 0 deletions

View File

@@ -0,0 +1,374 @@
// <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 backend.Data;
#nullable disable
namespace backend.Migrations
{
[DbContext(typeof(AppDbContext))]
[Migration("20260603125735_InitialCreate")]
partial class InitialCreate
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "8.0.0")
.HasAnnotation("Relational:MaxIdentifierLength", 128);
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
modelBuilder.Entity("backend.Models.KhatmItem", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("Points")
.HasColumnType("int");
b.Property<string>("Title")
.IsRequired()
.HasMaxLength(200)
.HasColumnType("nvarchar(200)");
b.HasKey("Id");
b.ToTable("KhatmItems");
b.HasData(
new
{
Id = 1,
Points = 5,
Title = "ختم نادعلی"
},
new
{
Id = 2,
Points = 10,
Title = "خطبه غدیر"
},
new
{
Id = 3,
Points = 7,
Title = "دعای توسل"
});
});
modelBuilder.Entity("backend.Models.QuizQuestion", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("CorrectOption")
.HasColumnType("int");
b.Property<string>("Option1")
.IsRequired()
.HasMaxLength(200)
.HasColumnType("nvarchar(200)");
b.Property<string>("Option2")
.IsRequired()
.HasMaxLength(200)
.HasColumnType("nvarchar(200)");
b.Property<string>("Option3")
.IsRequired()
.HasMaxLength(200)
.HasColumnType("nvarchar(200)");
b.Property<string>("Option4")
.IsRequired()
.HasMaxLength(200)
.HasColumnType("nvarchar(200)");
b.Property<string>("QuestionText")
.IsRequired()
.HasMaxLength(500)
.HasColumnType("nvarchar(500)");
b.HasKey("Id");
b.ToTable("QuizQuestions");
b.HasData(
new
{
Id = 1,
CorrectOption = 1,
Option1 = "سال ۱۰ هجری",
Option2 = "سال ۱۱ هجری",
Option3 = "سال ۹ هجری",
Option4 = "سال ۱۲ هجری",
QuestionText = "غدیر در چه سالی واقع شد؟"
},
new
{
Id = 2,
CorrectOption = 3,
Option1 = "ابوبکر",
Option2 = "عمر",
Option3 = "علی (ع)",
Option4 = "عثمان",
QuestionText = "پیامبر اکرم (ص) در غدیر چه کسی را به عنوان جانشین معرفی کردند؟"
},
new
{
Id = 3,
CorrectOption = 2,
Option1 = "مسجد النبی",
Option2 = "غدیر خم",
Option3 = "مکه",
Option4 = "مدینه",
QuestionText = "خطبه غدیر در کجا ایراد شد؟"
});
});
modelBuilder.Entity("backend.Models.User", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("Contact")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("nvarchar(50)");
b.Property<string>("FullName")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("nvarchar(100)");
b.Property<string>("TrackingCode")
.IsRequired()
.HasMaxLength(8)
.HasColumnType("nvarchar(8)");
b.HasKey("Id");
b.HasIndex("Contact")
.IsUnique();
b.HasIndex("TrackingCode")
.IsUnique();
b.ToTable("Users");
});
modelBuilder.Entity("backend.Models.UserKhatmSelection", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<bool>("IsSelected")
.HasColumnType("bit");
b.Property<int>("KhatmItemId")
.HasColumnType("int");
b.Property<DateTime>("LastModified")
.HasColumnType("datetime2");
b.Property<int>("UserId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("KhatmItemId");
b.HasIndex("UserId", "KhatmItemId")
.IsUnique();
b.ToTable("UserKhatmSelections");
});
modelBuilder.Entity("backend.Models.UserQuizAnswer", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<bool>("IsCorrect")
.HasColumnType("bit");
b.Property<int>("QuestionId")
.HasColumnType("int");
b.Property<int>("SelectedOption")
.HasColumnType("int");
b.Property<int>("UserQuizAttemptId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("QuestionId");
b.HasIndex("UserQuizAttemptId");
b.ToTable("UserQuizAnswers");
});
modelBuilder.Entity("backend.Models.UserQuizAttempt", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<DateTime>("CompletedAt")
.HasColumnType("datetime2");
b.Property<int>("CorrectAnswersCount")
.HasColumnType("int");
b.Property<int>("ParticipationPoints")
.HasColumnType("int");
b.Property<int>("TotalQuizPoints")
.HasColumnType("int");
b.Property<int>("UserId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("UserId")
.IsUnique();
b.ToTable("UserQuizAttempts");
});
modelBuilder.Entity("backend.Models.UserTotalScore", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("TotalPoints")
.HasColumnType("int");
b.Property<int>("UserId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("UserId")
.IsUnique();
b.ToTable("UserTotalScores");
});
modelBuilder.Entity("backend.Models.UserKhatmSelection", b =>
{
b.HasOne("backend.Models.KhatmItem", "KhatmItem")
.WithMany("UserSelections")
.HasForeignKey("KhatmItemId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("backend.Models.User", "User")
.WithMany("KhatmSelections")
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("KhatmItem");
b.Navigation("User");
});
modelBuilder.Entity("backend.Models.UserQuizAnswer", b =>
{
b.HasOne("backend.Models.QuizQuestion", "Question")
.WithMany("Answers")
.HasForeignKey("QuestionId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("backend.Models.UserQuizAttempt", "QuizAttempt")
.WithMany("Answers")
.HasForeignKey("UserQuizAttemptId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Question");
b.Navigation("QuizAttempt");
});
modelBuilder.Entity("backend.Models.UserQuizAttempt", b =>
{
b.HasOne("backend.Models.User", "User")
.WithOne("QuizAttempt")
.HasForeignKey("backend.Models.UserQuizAttempt", "UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("User");
});
modelBuilder.Entity("backend.Models.UserTotalScore", b =>
{
b.HasOne("backend.Models.User", "User")
.WithOne("TotalScore")
.HasForeignKey("backend.Models.UserTotalScore", "UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("User");
});
modelBuilder.Entity("backend.Models.KhatmItem", b =>
{
b.Navigation("UserSelections");
});
modelBuilder.Entity("backend.Models.QuizQuestion", b =>
{
b.Navigation("Answers");
});
modelBuilder.Entity("backend.Models.User", b =>
{
b.Navigation("KhatmSelections");
b.Navigation("QuizAttempt");
b.Navigation("TotalScore");
});
modelBuilder.Entity("backend.Models.UserQuizAttempt", b =>
{
b.Navigation("Answers");
});
#pragma warning restore 612, 618
}
}
}

View File

@@ -0,0 +1,253 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
#pragma warning disable CA1814 // Prefer jagged arrays over multidimensional
namespace backend.Migrations
{
/// <inheritdoc />
public partial class InitialCreate : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "KhatmItems",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Title = table.Column<string>(type: "nvarchar(200)", maxLength: 200, nullable: false),
Points = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_KhatmItems", x => x.Id);
});
migrationBuilder.CreateTable(
name: "QuizQuestions",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
QuestionText = table.Column<string>(type: "nvarchar(500)", maxLength: 500, nullable: false),
Option1 = table.Column<string>(type: "nvarchar(200)", maxLength: 200, nullable: false),
Option2 = table.Column<string>(type: "nvarchar(200)", maxLength: 200, nullable: false),
Option3 = table.Column<string>(type: "nvarchar(200)", maxLength: 200, nullable: false),
Option4 = table.Column<string>(type: "nvarchar(200)", maxLength: 200, nullable: false),
CorrectOption = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_QuizQuestions", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Users",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
FullName = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: false),
Contact = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
TrackingCode = table.Column<string>(type: "nvarchar(8)", maxLength: 8, nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Users", x => x.Id);
});
migrationBuilder.CreateTable(
name: "UserKhatmSelections",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
UserId = table.Column<int>(type: "int", nullable: false),
KhatmItemId = table.Column<int>(type: "int", nullable: false),
IsSelected = table.Column<bool>(type: "bit", nullable: false),
LastModified = table.Column<DateTime>(type: "datetime2", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_UserKhatmSelections", x => x.Id);
table.ForeignKey(
name: "FK_UserKhatmSelections_KhatmItems_KhatmItemId",
column: x => x.KhatmItemId,
principalTable: "KhatmItems",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_UserKhatmSelections_Users_UserId",
column: x => x.UserId,
principalTable: "Users",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "UserQuizAttempts",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
UserId = table.Column<int>(type: "int", nullable: false),
ParticipationPoints = table.Column<int>(type: "int", nullable: false),
CorrectAnswersCount = table.Column<int>(type: "int", nullable: false),
TotalQuizPoints = table.Column<int>(type: "int", nullable: false),
CompletedAt = table.Column<DateTime>(type: "datetime2", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_UserQuizAttempts", x => x.Id);
table.ForeignKey(
name: "FK_UserQuizAttempts_Users_UserId",
column: x => x.UserId,
principalTable: "Users",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "UserTotalScores",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
UserId = table.Column<int>(type: "int", nullable: false),
TotalPoints = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_UserTotalScores", x => x.Id);
table.ForeignKey(
name: "FK_UserTotalScores_Users_UserId",
column: x => x.UserId,
principalTable: "Users",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "UserQuizAnswers",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
UserQuizAttemptId = table.Column<int>(type: "int", nullable: false),
QuestionId = table.Column<int>(type: "int", nullable: false),
SelectedOption = table.Column<int>(type: "int", nullable: false),
IsCorrect = table.Column<bool>(type: "bit", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_UserQuizAnswers", x => x.Id);
table.ForeignKey(
name: "FK_UserQuizAnswers_QuizQuestions_QuestionId",
column: x => x.QuestionId,
principalTable: "QuizQuestions",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_UserQuizAnswers_UserQuizAttempts_UserQuizAttemptId",
column: x => x.UserQuizAttemptId,
principalTable: "UserQuizAttempts",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.InsertData(
table: "KhatmItems",
columns: new[] { "Id", "Points", "Title" },
values: new object[,]
{
{ 1, 5, "ختم نادعلی" },
{ 2, 10, "خطبه غدیر" },
{ 3, 7, "دعای توسل" }
});
migrationBuilder.InsertData(
table: "QuizQuestions",
columns: new[] { "Id", "CorrectOption", "Option1", "Option2", "Option3", "Option4", "QuestionText" },
values: new object[,]
{
{ 1, 1, "سال ۱۰ هجری", "سال ۱۱ هجری", "سال ۹ هجری", "سال ۱۲ هجری", "غدیر در چه سالی واقع شد؟" },
{ 2, 3, "ابوبکر", "عمر", "علی (ع)", "عثمان", "پیامبر اکرم (ص) در غدیر چه کسی را به عنوان جانشین معرفی کردند؟" },
{ 3, 2, "مسجد النبی", "غدیر خم", "مکه", "مدینه", "خطبه غدیر در کجا ایراد شد؟" }
});
migrationBuilder.CreateIndex(
name: "IX_UserKhatmSelections_KhatmItemId",
table: "UserKhatmSelections",
column: "KhatmItemId");
migrationBuilder.CreateIndex(
name: "IX_UserKhatmSelections_UserId_KhatmItemId",
table: "UserKhatmSelections",
columns: new[] { "UserId", "KhatmItemId" },
unique: true);
migrationBuilder.CreateIndex(
name: "IX_UserQuizAnswers_QuestionId",
table: "UserQuizAnswers",
column: "QuestionId");
migrationBuilder.CreateIndex(
name: "IX_UserQuizAnswers_UserQuizAttemptId",
table: "UserQuizAnswers",
column: "UserQuizAttemptId");
migrationBuilder.CreateIndex(
name: "IX_UserQuizAttempts_UserId",
table: "UserQuizAttempts",
column: "UserId",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_Users_Contact",
table: "Users",
column: "Contact",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_Users_TrackingCode",
table: "Users",
column: "TrackingCode",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_UserTotalScores_UserId",
table: "UserTotalScores",
column: "UserId",
unique: true);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "UserKhatmSelections");
migrationBuilder.DropTable(
name: "UserQuizAnswers");
migrationBuilder.DropTable(
name: "UserTotalScores");
migrationBuilder.DropTable(
name: "KhatmItems");
migrationBuilder.DropTable(
name: "QuizQuestions");
migrationBuilder.DropTable(
name: "UserQuizAttempts");
migrationBuilder.DropTable(
name: "Users");
}
}
}

View File

@@ -0,0 +1,381 @@
// <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 backend.Data;
#nullable disable
namespace backend.Migrations
{
[DbContext(typeof(AppDbContext))]
[Migration("20260603142557_AddKhatmItemUrl")]
partial class AddKhatmItemUrl
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "8.0.0")
.HasAnnotation("Relational:MaxIdentifierLength", 128);
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
modelBuilder.Entity("backend.Models.KhatmItem", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("Points")
.HasColumnType("int");
b.Property<string>("Title")
.IsRequired()
.HasMaxLength(200)
.HasColumnType("nvarchar(200)");
b.Property<string>("Url")
.HasMaxLength(500)
.HasColumnType("nvarchar(500)");
b.HasKey("Id");
b.ToTable("KhatmItems");
b.HasData(
new
{
Id = 1,
Points = 5,
Title = "ختم نادعلی",
Url = "https://example.com/khatm/nadali"
},
new
{
Id = 2,
Points = 10,
Title = "خطبه غدیر",
Url = "https://example.com/khatm/ghadir"
},
new
{
Id = 3,
Points = 7,
Title = "دعای توسل",
Url = "https://example.com/khatm/tavassol"
});
});
modelBuilder.Entity("backend.Models.QuizQuestion", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("CorrectOption")
.HasColumnType("int");
b.Property<string>("Option1")
.IsRequired()
.HasMaxLength(200)
.HasColumnType("nvarchar(200)");
b.Property<string>("Option2")
.IsRequired()
.HasMaxLength(200)
.HasColumnType("nvarchar(200)");
b.Property<string>("Option3")
.IsRequired()
.HasMaxLength(200)
.HasColumnType("nvarchar(200)");
b.Property<string>("Option4")
.IsRequired()
.HasMaxLength(200)
.HasColumnType("nvarchar(200)");
b.Property<string>("QuestionText")
.IsRequired()
.HasMaxLength(500)
.HasColumnType("nvarchar(500)");
b.HasKey("Id");
b.ToTable("QuizQuestions");
b.HasData(
new
{
Id = 1,
CorrectOption = 1,
Option1 = "سال ۱۰ هجری",
Option2 = "سال ۱۱ هجری",
Option3 = "سال ۹ هجری",
Option4 = "سال ۱۲ هجری",
QuestionText = "غدیر در چه سالی واقع شد؟"
},
new
{
Id = 2,
CorrectOption = 3,
Option1 = "ابوبکر",
Option2 = "عمر",
Option3 = "علی (ع)",
Option4 = "عثمان",
QuestionText = "پیامبر اکرم (ص) در غدیر چه کسی را به عنوان جانشین معرفی کردند؟"
},
new
{
Id = 3,
CorrectOption = 2,
Option1 = "مسجد النبی",
Option2 = "غدیر خم",
Option3 = "مکه",
Option4 = "مدینه",
QuestionText = "خطبه غدیر در کجا ایراد شد؟"
});
});
modelBuilder.Entity("backend.Models.User", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("Contact")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("nvarchar(50)");
b.Property<string>("FullName")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("nvarchar(100)");
b.Property<string>("TrackingCode")
.IsRequired()
.HasMaxLength(8)
.HasColumnType("nvarchar(8)");
b.HasKey("Id");
b.HasIndex("Contact")
.IsUnique();
b.HasIndex("TrackingCode")
.IsUnique();
b.ToTable("Users");
});
modelBuilder.Entity("backend.Models.UserKhatmSelection", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<bool>("IsSelected")
.HasColumnType("bit");
b.Property<int>("KhatmItemId")
.HasColumnType("int");
b.Property<DateTime>("LastModified")
.HasColumnType("datetime2");
b.Property<int>("UserId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("KhatmItemId");
b.HasIndex("UserId", "KhatmItemId")
.IsUnique();
b.ToTable("UserKhatmSelections");
});
modelBuilder.Entity("backend.Models.UserQuizAnswer", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<bool>("IsCorrect")
.HasColumnType("bit");
b.Property<int>("QuestionId")
.HasColumnType("int");
b.Property<int>("SelectedOption")
.HasColumnType("int");
b.Property<int>("UserQuizAttemptId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("QuestionId");
b.HasIndex("UserQuizAttemptId");
b.ToTable("UserQuizAnswers");
});
modelBuilder.Entity("backend.Models.UserQuizAttempt", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<DateTime>("CompletedAt")
.HasColumnType("datetime2");
b.Property<int>("CorrectAnswersCount")
.HasColumnType("int");
b.Property<int>("ParticipationPoints")
.HasColumnType("int");
b.Property<int>("TotalQuizPoints")
.HasColumnType("int");
b.Property<int>("UserId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("UserId")
.IsUnique();
b.ToTable("UserQuizAttempts");
});
modelBuilder.Entity("backend.Models.UserTotalScore", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("TotalPoints")
.HasColumnType("int");
b.Property<int>("UserId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("UserId")
.IsUnique();
b.ToTable("UserTotalScores");
});
modelBuilder.Entity("backend.Models.UserKhatmSelection", b =>
{
b.HasOne("backend.Models.KhatmItem", "KhatmItem")
.WithMany("UserSelections")
.HasForeignKey("KhatmItemId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("backend.Models.User", "User")
.WithMany("KhatmSelections")
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("KhatmItem");
b.Navigation("User");
});
modelBuilder.Entity("backend.Models.UserQuizAnswer", b =>
{
b.HasOne("backend.Models.QuizQuestion", "Question")
.WithMany("Answers")
.HasForeignKey("QuestionId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("backend.Models.UserQuizAttempt", "QuizAttempt")
.WithMany("Answers")
.HasForeignKey("UserQuizAttemptId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Question");
b.Navigation("QuizAttempt");
});
modelBuilder.Entity("backend.Models.UserQuizAttempt", b =>
{
b.HasOne("backend.Models.User", "User")
.WithOne("QuizAttempt")
.HasForeignKey("backend.Models.UserQuizAttempt", "UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("User");
});
modelBuilder.Entity("backend.Models.UserTotalScore", b =>
{
b.HasOne("backend.Models.User", "User")
.WithOne("TotalScore")
.HasForeignKey("backend.Models.UserTotalScore", "UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("User");
});
modelBuilder.Entity("backend.Models.KhatmItem", b =>
{
b.Navigation("UserSelections");
});
modelBuilder.Entity("backend.Models.QuizQuestion", b =>
{
b.Navigation("Answers");
});
modelBuilder.Entity("backend.Models.User", b =>
{
b.Navigation("KhatmSelections");
b.Navigation("QuizAttempt");
b.Navigation("TotalScore");
});
modelBuilder.Entity("backend.Models.UserQuizAttempt", b =>
{
b.Navigation("Answers");
});
#pragma warning restore 612, 618
}
}
}

View File

@@ -0,0 +1,50 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace backend.Migrations
{
/// <inheritdoc />
public partial class AddKhatmItemUrl : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<string>(
name: "Url",
table: "KhatmItems",
type: "nvarchar(500)",
maxLength: 500,
nullable: true);
migrationBuilder.UpdateData(
table: "KhatmItems",
keyColumn: "Id",
keyValue: 1,
column: "Url",
value: "https://example.com/khatm/nadali");
migrationBuilder.UpdateData(
table: "KhatmItems",
keyColumn: "Id",
keyValue: 2,
column: "Url",
value: "https://example.com/khatm/ghadir");
migrationBuilder.UpdateData(
table: "KhatmItems",
keyColumn: "Id",
keyValue: 3,
column: "Url",
value: "https://example.com/khatm/tavassol");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "Url",
table: "KhatmItems");
}
}
}

View File

@@ -0,0 +1,381 @@
// <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 backend.Data;
#nullable disable
namespace backend.Migrations
{
[DbContext(typeof(AppDbContext))]
[Migration("20260603144334_UpdateTrackingCodeLength")]
partial class UpdateTrackingCodeLength
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "8.0.0")
.HasAnnotation("Relational:MaxIdentifierLength", 128);
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
modelBuilder.Entity("backend.Models.KhatmItem", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("Points")
.HasColumnType("int");
b.Property<string>("Title")
.IsRequired()
.HasMaxLength(200)
.HasColumnType("nvarchar(200)");
b.Property<string>("Url")
.HasMaxLength(500)
.HasColumnType("nvarchar(500)");
b.HasKey("Id");
b.ToTable("KhatmItems");
b.HasData(
new
{
Id = 1,
Points = 5,
Title = "ختم نادعلی",
Url = "https://example.com/khatm/nadali"
},
new
{
Id = 2,
Points = 10,
Title = "خطبه غدیر",
Url = "https://example.com/khatm/ghadir"
},
new
{
Id = 3,
Points = 7,
Title = "دعای توسل",
Url = "https://example.com/khatm/tavassol"
});
});
modelBuilder.Entity("backend.Models.QuizQuestion", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("CorrectOption")
.HasColumnType("int");
b.Property<string>("Option1")
.IsRequired()
.HasMaxLength(200)
.HasColumnType("nvarchar(200)");
b.Property<string>("Option2")
.IsRequired()
.HasMaxLength(200)
.HasColumnType("nvarchar(200)");
b.Property<string>("Option3")
.IsRequired()
.HasMaxLength(200)
.HasColumnType("nvarchar(200)");
b.Property<string>("Option4")
.IsRequired()
.HasMaxLength(200)
.HasColumnType("nvarchar(200)");
b.Property<string>("QuestionText")
.IsRequired()
.HasMaxLength(500)
.HasColumnType("nvarchar(500)");
b.HasKey("Id");
b.ToTable("QuizQuestions");
b.HasData(
new
{
Id = 1,
CorrectOption = 1,
Option1 = "سال ۱۰ هجری",
Option2 = "سال ۱۱ هجری",
Option3 = "سال ۹ هجری",
Option4 = "سال ۱۲ هجری",
QuestionText = "غدیر در چه سالی واقع شد؟"
},
new
{
Id = 2,
CorrectOption = 3,
Option1 = "ابوبکر",
Option2 = "عمر",
Option3 = "علی (ع)",
Option4 = "عثمان",
QuestionText = "پیامبر اکرم (ص) در غدیر چه کسی را به عنوان جانشین معرفی کردند؟"
},
new
{
Id = 3,
CorrectOption = 2,
Option1 = "مسجد النبی",
Option2 = "غدیر خم",
Option3 = "مکه",
Option4 = "مدینه",
QuestionText = "خطبه غدیر در کجا ایراد شد؟"
});
});
modelBuilder.Entity("backend.Models.User", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("Contact")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("nvarchar(50)");
b.Property<string>("FullName")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("nvarchar(100)");
b.Property<string>("TrackingCode")
.IsRequired()
.HasMaxLength(4)
.HasColumnType("nvarchar(4)");
b.HasKey("Id");
b.HasIndex("Contact")
.IsUnique();
b.HasIndex("TrackingCode")
.IsUnique();
b.ToTable("Users");
});
modelBuilder.Entity("backend.Models.UserKhatmSelection", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<bool>("IsSelected")
.HasColumnType("bit");
b.Property<int>("KhatmItemId")
.HasColumnType("int");
b.Property<DateTime>("LastModified")
.HasColumnType("datetime2");
b.Property<int>("UserId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("KhatmItemId");
b.HasIndex("UserId", "KhatmItemId")
.IsUnique();
b.ToTable("UserKhatmSelections");
});
modelBuilder.Entity("backend.Models.UserQuizAnswer", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<bool>("IsCorrect")
.HasColumnType("bit");
b.Property<int>("QuestionId")
.HasColumnType("int");
b.Property<int>("SelectedOption")
.HasColumnType("int");
b.Property<int>("UserQuizAttemptId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("QuestionId");
b.HasIndex("UserQuizAttemptId");
b.ToTable("UserQuizAnswers");
});
modelBuilder.Entity("backend.Models.UserQuizAttempt", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<DateTime>("CompletedAt")
.HasColumnType("datetime2");
b.Property<int>("CorrectAnswersCount")
.HasColumnType("int");
b.Property<int>("ParticipationPoints")
.HasColumnType("int");
b.Property<int>("TotalQuizPoints")
.HasColumnType("int");
b.Property<int>("UserId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("UserId")
.IsUnique();
b.ToTable("UserQuizAttempts");
});
modelBuilder.Entity("backend.Models.UserTotalScore", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("TotalPoints")
.HasColumnType("int");
b.Property<int>("UserId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("UserId")
.IsUnique();
b.ToTable("UserTotalScores");
});
modelBuilder.Entity("backend.Models.UserKhatmSelection", b =>
{
b.HasOne("backend.Models.KhatmItem", "KhatmItem")
.WithMany("UserSelections")
.HasForeignKey("KhatmItemId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("backend.Models.User", "User")
.WithMany("KhatmSelections")
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("KhatmItem");
b.Navigation("User");
});
modelBuilder.Entity("backend.Models.UserQuizAnswer", b =>
{
b.HasOne("backend.Models.QuizQuestion", "Question")
.WithMany("Answers")
.HasForeignKey("QuestionId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("backend.Models.UserQuizAttempt", "QuizAttempt")
.WithMany("Answers")
.HasForeignKey("UserQuizAttemptId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Question");
b.Navigation("QuizAttempt");
});
modelBuilder.Entity("backend.Models.UserQuizAttempt", b =>
{
b.HasOne("backend.Models.User", "User")
.WithOne("QuizAttempt")
.HasForeignKey("backend.Models.UserQuizAttempt", "UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("User");
});
modelBuilder.Entity("backend.Models.UserTotalScore", b =>
{
b.HasOne("backend.Models.User", "User")
.WithOne("TotalScore")
.HasForeignKey("backend.Models.UserTotalScore", "UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("User");
});
modelBuilder.Entity("backend.Models.KhatmItem", b =>
{
b.Navigation("UserSelections");
});
modelBuilder.Entity("backend.Models.QuizQuestion", b =>
{
b.Navigation("Answers");
});
modelBuilder.Entity("backend.Models.User", b =>
{
b.Navigation("KhatmSelections");
b.Navigation("QuizAttempt");
b.Navigation("TotalScore");
});
modelBuilder.Entity("backend.Models.UserQuizAttempt", b =>
{
b.Navigation("Answers");
});
#pragma warning restore 612, 618
}
}
}

View File

@@ -0,0 +1,57 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace backend.Migrations
{
/// <inheritdoc />
public partial class UpdateTrackingCodeLength : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
// First, update existing tracking codes to 4-digit numeric values
// Using a hash-based approach to generate unique 4-digit codes from existing ones
migrationBuilder.Sql(@"
DECLARE @Id int, @RowNum int, @NewCode nvarchar(4)
DECLARE code_cursor CURSOR FOR
SELECT Id, ROW_NUMBER() OVER (ORDER BY Id) AS RowNum
FROM Users
OPEN code_cursor
FETCH NEXT FROM code_cursor INTO @Id, @RowNum
WHILE @@FETCH_STATUS = 0
BEGIN
SET @NewCode = RIGHT('0000' + CAST((@RowNum + 1000) AS nvarchar(4)), 4)
UPDATE Users SET TrackingCode = @NewCode WHERE Id = @Id
FETCH NEXT FROM code_cursor INTO @Id, @RowNum
END
CLOSE code_cursor
DEALLOCATE code_cursor
");
migrationBuilder.AlterColumn<string>(
name: "TrackingCode",
table: "Users",
type: "nvarchar(4)",
maxLength: 4,
nullable: false,
oldClrType: typeof(string),
oldType: "nvarchar(8)",
oldMaxLength: 8);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterColumn<string>(
name: "TrackingCode",
table: "Users",
type: "nvarchar(8)",
maxLength: 8,
nullable: false,
oldClrType: typeof(string),
oldType: "nvarchar(4)",
oldMaxLength: 4);
}
}
}

View File

@@ -0,0 +1,451 @@
// <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 backend.Data;
#nullable disable
namespace backend.Migrations
{
[DbContext(typeof(AppDbContext))]
[Migration("20260603144804_SeedQuizQuestions")]
partial class SeedQuizQuestions
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "8.0.0")
.HasAnnotation("Relational:MaxIdentifierLength", 128);
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
modelBuilder.Entity("backend.Models.KhatmItem", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("Points")
.HasColumnType("int");
b.Property<string>("Title")
.IsRequired()
.HasMaxLength(200)
.HasColumnType("nvarchar(200)");
b.Property<string>("Url")
.HasMaxLength(500)
.HasColumnType("nvarchar(500)");
b.HasKey("Id");
b.ToTable("KhatmItems");
b.HasData(
new
{
Id = 1,
Points = 5,
Title = "ختم نادعلی",
Url = "https://example.com/khatm/nadali"
},
new
{
Id = 2,
Points = 10,
Title = "خطبه غدیر",
Url = "https://example.com/khatm/ghadir"
},
new
{
Id = 3,
Points = 7,
Title = "دعای توسل",
Url = "https://example.com/khatm/tavassol"
});
});
modelBuilder.Entity("backend.Models.QuizQuestion", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("CorrectOption")
.HasColumnType("int");
b.Property<string>("Option1")
.IsRequired()
.HasMaxLength(200)
.HasColumnType("nvarchar(200)");
b.Property<string>("Option2")
.IsRequired()
.HasMaxLength(200)
.HasColumnType("nvarchar(200)");
b.Property<string>("Option3")
.IsRequired()
.HasMaxLength(200)
.HasColumnType("nvarchar(200)");
b.Property<string>("Option4")
.IsRequired()
.HasMaxLength(200)
.HasColumnType("nvarchar(200)");
b.Property<string>("QuestionText")
.IsRequired()
.HasMaxLength(500)
.HasColumnType("nvarchar(500)");
b.HasKey("Id");
b.ToTable("QuizQuestions");
b.HasData(
new
{
Id = 1,
CorrectOption = 4,
Option1 = "آيه 31 سوره نور",
Option2 = "آيه 58 – 60 سوره نور",
Option3 = "آيه 59 – 60 سوره احزاب",
Option4 = "آيه 59 – 60 سوره نساء",
QuestionText = "كدام يك از آيات زير مربوط به حجاب نمي باشد؟"
},
new
{
Id = 2,
CorrectOption = 3,
Option1 = "پوشش – عفاف",
Option2 = "ترك نظر – پوشش",
Option3 = "ترك نظر – پاكدامني",
Option4 = "پوشش – پاكدامني",
QuestionText = "اين قسمت از آيه 31 سوره نور « قل للمومنات يغضضن من ابصار هن و يحفظن فروجهن» بيانگر كدام دو تكليف است؟"
},
new
{
Id = 3,
CorrectOption = 1,
Option1 = "زنان سالخورده اي كه اميدي به ازدواج ايشان نمي باشد",
Option2 = "بردگان و مملوكان",
Option3 = "طفيلياني كه نيازي به زن ندارند",
Option4 = "اطفال نابالغ ولو مميز نزديك به بلوغ",
QuestionText = "منظور از (( قواعد )) در سوره نور آيات 58-60 چه كساني هستند؟"
},
new
{
Id = 4,
CorrectOption = 3,
Option1 = "در مورد ثمرات ولایت و محبت اهل‌بیت",
Option2 = "در مورد جنبه غضب الهی",
Option3 = "در مورد امام مهدی علیه‌السلام",
Option4 = "اقرار لسانی",
QuestionText = "هشتمین بخش خطبه غدیر در چه موضوعی است؟"
},
new
{
Id = 5,
CorrectOption = 1,
Option1 = "این لقب به دستور مستقیم از جانب خداوند به ایشان داده شد",
Option2 = "پیامبر اکرم، خودشان این لقب را انتخاب کردند",
Option3 = "مردم به علت فضائل بسیار ایشان، این لقب را انتخاب کردند",
Option4 = "به درخواست خود ایشان بود",
QuestionText = "لقب «امیرالمؤمنین» توسط چه کسی به مولا علی علیه‌السلام اطلاق شد؟"
},
new
{
Id = 6,
CorrectOption = 3,
Option1 = "کسانی که خبر اسلام به آنان نرسیده است",
Option2 = "کسانی که در مدیریت زمان ضعیف هستند",
Option3 = "دشمنان آل محمد (صلی‌الله‌علیه‌وآله)",
Option4 = "اهل کتاب",
QuestionText = "طبق فرمایش پیامبر اکرم در غدیر، عبارت «إِنَّ الإِنسَانَ لَفِي خُسْرٍ»، «انسان در زیان است» درباره چه کسانی است؟"
},
new
{
Id = 7,
CorrectOption = 3,
Option1 = "سوره کهف آیه ۲۸",
Option2 = "سوره انعام آیه ۶۱",
Option3 = "سوره زمر ۵۶",
Option4 = "سوره طه ۴۵",
QuestionText = "در کدام آیه از قرآن مجید خداوند می فرماید که درباره علی تفریط و کوتاهی نکنید؟"
},
new
{
Id = 8,
CorrectOption = 2,
Option1 = "تعيين امامت ،علی عليه السلام",
Option2 = "تبليغ امامت، علی عليه السلام",
Option3 = "تعيين و تبليغ امامت، علی عليه السلام",
Option4 = "سپردن تعیین امامت به مردم",
QuestionText = "طبق آیه 67 سوره مائده وظيفه رسول خدا در برابر امامت چيست و آيه در شأن چه كسی نازل شده است؟\n«يَا أَيُّهَا الرَّسُولُ بَلِّغْ مَا أُنْزِلَ إِلَيْكَ مِنْ رَبِّكَ وَإِنْ لَمْ تَفْعَلْ فَمَا بَلَّغْتَ رِسَالَتَهُ ...»"
},
new
{
Id = 9,
CorrectOption = 1,
Option1 = "عید غدیر، روز تبلیغ و معرفی امیرالمومنین به عنوان جانشین پیامبر",
Option2 = "روز جمعه",
Option3 = "عید قربان، حج تمتع",
Option4 = "عید فطر، پایان یک ماه بندگی",
QuestionText = "طبق روایت امام رضا علیه السلام برترین عید امت اسلامی کدام است؟"
},
new
{
Id = 10,
CorrectOption = 4,
Option1 = "با ابلاغ ولایت و امامت امیرالمومنین(علیه السلام) توسط پیامبر اکرم(صلی الله علیه و آله) دین کامل گشت",
Option2 = "خداوند با ابلاغ ولایت و امامت امیرالمومنین(علیه السلام) و یازده فرزند پاکشان از اسلام اعلام رضایت فرمودند",
Option3 = "شرط اینکه دین شخص مسلمان مورد رضایت خداوند متعال قرار گیرد پذیرش ولایت و امامت ائمه (علیهم السلام) است",
Option4 = "امامت از فروع دین بوده و قبول یا عدم پذیرش آن لطمه‌ای به آن شخص وارد نمی‌کند",
QuestionText = "با توجه به مطلبی که در آیه شریفه «الْيَوْمَ أَكْمَلْتُ لَكُمْ دِينَكُمْ وَ أَتْمَمْتُ عَلَيْكُمْ نِعْمَتِي وَ رَضِيتُ لَكُمُ الْإِسْلامَ دِينا» در روز غدیر نازل گشته است. کدام گزینه صحیح نمی‌باشد؟"
});
});
modelBuilder.Entity("backend.Models.User", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("Contact")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("nvarchar(50)");
b.Property<string>("FullName")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("nvarchar(100)");
b.Property<string>("TrackingCode")
.IsRequired()
.HasMaxLength(4)
.HasColumnType("nvarchar(4)");
b.HasKey("Id");
b.HasIndex("Contact")
.IsUnique();
b.HasIndex("TrackingCode")
.IsUnique();
b.ToTable("Users");
});
modelBuilder.Entity("backend.Models.UserKhatmSelection", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<bool>("IsSelected")
.HasColumnType("bit");
b.Property<int>("KhatmItemId")
.HasColumnType("int");
b.Property<DateTime>("LastModified")
.HasColumnType("datetime2");
b.Property<int>("UserId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("KhatmItemId");
b.HasIndex("UserId", "KhatmItemId")
.IsUnique();
b.ToTable("UserKhatmSelections");
});
modelBuilder.Entity("backend.Models.UserQuizAnswer", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<bool>("IsCorrect")
.HasColumnType("bit");
b.Property<int>("QuestionId")
.HasColumnType("int");
b.Property<int>("SelectedOption")
.HasColumnType("int");
b.Property<int>("UserQuizAttemptId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("QuestionId");
b.HasIndex("UserQuizAttemptId");
b.ToTable("UserQuizAnswers");
});
modelBuilder.Entity("backend.Models.UserQuizAttempt", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<DateTime>("CompletedAt")
.HasColumnType("datetime2");
b.Property<int>("CorrectAnswersCount")
.HasColumnType("int");
b.Property<int>("ParticipationPoints")
.HasColumnType("int");
b.Property<int>("TotalQuizPoints")
.HasColumnType("int");
b.Property<int>("UserId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("UserId")
.IsUnique();
b.ToTable("UserQuizAttempts");
});
modelBuilder.Entity("backend.Models.UserTotalScore", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("TotalPoints")
.HasColumnType("int");
b.Property<int>("UserId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("UserId")
.IsUnique();
b.ToTable("UserTotalScores");
});
modelBuilder.Entity("backend.Models.UserKhatmSelection", b =>
{
b.HasOne("backend.Models.KhatmItem", "KhatmItem")
.WithMany("UserSelections")
.HasForeignKey("KhatmItemId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("backend.Models.User", "User")
.WithMany("KhatmSelections")
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("KhatmItem");
b.Navigation("User");
});
modelBuilder.Entity("backend.Models.UserQuizAnswer", b =>
{
b.HasOne("backend.Models.QuizQuestion", "Question")
.WithMany("Answers")
.HasForeignKey("QuestionId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("backend.Models.UserQuizAttempt", "QuizAttempt")
.WithMany("Answers")
.HasForeignKey("UserQuizAttemptId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Question");
b.Navigation("QuizAttempt");
});
modelBuilder.Entity("backend.Models.UserQuizAttempt", b =>
{
b.HasOne("backend.Models.User", "User")
.WithOne("QuizAttempt")
.HasForeignKey("backend.Models.UserQuizAttempt", "UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("User");
});
modelBuilder.Entity("backend.Models.UserTotalScore", b =>
{
b.HasOne("backend.Models.User", "User")
.WithOne("TotalScore")
.HasForeignKey("backend.Models.UserTotalScore", "UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("User");
});
modelBuilder.Entity("backend.Models.KhatmItem", b =>
{
b.Navigation("UserSelections");
});
modelBuilder.Entity("backend.Models.QuizQuestion", b =>
{
b.Navigation("Answers");
});
modelBuilder.Entity("backend.Models.User", b =>
{
b.Navigation("KhatmSelections");
b.Navigation("QuizAttempt");
b.Navigation("TotalScore");
});
modelBuilder.Entity("backend.Models.UserQuizAttempt", b =>
{
b.Navigation("Answers");
});
#pragma warning restore 612, 618
}
}
}

View File

@@ -0,0 +1,111 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
#pragma warning disable CA1814 // Prefer jagged arrays over multidimensional
namespace backend.Migrations
{
/// <inheritdoc />
public partial class SeedQuizQuestions : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.UpdateData(
table: "QuizQuestions",
keyColumn: "Id",
keyValue: 1,
columns: new[] { "CorrectOption", "Option1", "Option2", "Option3", "Option4", "QuestionText" },
values: new object[] { 4, "آيه 31 سوره نور", "آيه 58 – 60 سوره نور", "آيه 59 – 60 سوره احزاب", "آيه 59 – 60 سوره نساء", "كدام يك از آيات زير مربوط به حجاب نمي باشد؟" });
migrationBuilder.UpdateData(
table: "QuizQuestions",
keyColumn: "Id",
keyValue: 2,
columns: new[] { "Option1", "Option2", "Option3", "Option4", "QuestionText" },
values: new object[] { "پوشش – عفاف", "ترك نظر – پوشش", "ترك نظر – پاكدامني", "پوشش – پاكدامني", "اين قسمت از آيه 31 سوره نور « قل للمومنات يغضضن من ابصار هن و يحفظن فروجهن» بيانگر كدام دو تكليف است؟" });
migrationBuilder.UpdateData(
table: "QuizQuestions",
keyColumn: "Id",
keyValue: 3,
columns: new[] { "CorrectOption", "Option1", "Option2", "Option3", "Option4", "QuestionText" },
values: new object[] { 1, "زنان سالخورده اي كه اميدي به ازدواج ايشان نمي باشد", "بردگان و مملوكان", "طفيلياني كه نيازي به زن ندارند", "اطفال نابالغ ولو مميز نزديك به بلوغ", "منظور از (( قواعد )) در سوره نور آيات 58-60 چه كساني هستند؟" });
migrationBuilder.InsertData(
table: "QuizQuestions",
columns: new[] { "Id", "CorrectOption", "Option1", "Option2", "Option3", "Option4", "QuestionText" },
values: new object[,]
{
{ 4, 3, "در مورد ثمرات ولایت و محبت اهل‌بیت", "در مورد جنبه غضب الهی", "در مورد امام مهدی علیه‌السلام", "اقرار لسانی", "هشتمین بخش خطبه غدیر در چه موضوعی است؟" },
{ 5, 1, "این لقب به دستور مستقیم از جانب خداوند به ایشان داده شد", "پیامبر اکرم، خودشان این لقب را انتخاب کردند", "مردم به علت فضائل بسیار ایشان، این لقب را انتخاب کردند", "به درخواست خود ایشان بود", "لقب «امیرالمؤمنین» توسط چه کسی به مولا علی علیه‌السلام اطلاق شد؟" },
{ 6, 3, "کسانی که خبر اسلام به آنان نرسیده است", "کسانی که در مدیریت زمان ضعیف هستند", "دشمنان آل محمد (صلی‌الله‌علیه‌وآله)", "اهل کتاب", "طبق فرمایش پیامبر اکرم در غدیر، عبارت «إِنَّ الإِنسَانَ لَفِي خُسْرٍ»، «انسان در زیان است» درباره چه کسانی است؟" },
{ 7, 3, "سوره کهف آیه ۲۸", "سوره انعام آیه ۶۱", "سوره زمر ۵۶", "سوره طه ۴۵", "در کدام آیه از قرآن مجید خداوند می فرماید که درباره علی تفریط و کوتاهی نکنید؟" },
{ 8, 2, "تعيين امامت ،علی عليه السلام", "تبليغ امامت، علی عليه السلام", "تعيين و تبليغ امامت، علی عليه السلام", "سپردن تعیین امامت به مردم", "طبق آیه 67 سوره مائده وظيفه رسول خدا در برابر امامت چيست و آيه در شأن چه كسی نازل شده است؟\n«يَا أَيُّهَا الرَّسُولُ بَلِّغْ مَا أُنْزِلَ إِلَيْكَ مِنْ رَبِّكَ وَإِنْ لَمْ تَفْعَلْ فَمَا بَلَّغْتَ رِسَالَتَهُ ...»" },
{ 9, 1, "عید غدیر، روز تبلیغ و معرفی امیرالمومنین به عنوان جانشین پیامبر", "روز جمعه", "عید قربان، حج تمتع", "عید فطر، پایان یک ماه بندگی", "طبق روایت امام رضا علیه السلام برترین عید امت اسلامی کدام است؟" },
{ 10, 4, "با ابلاغ ولایت و امامت امیرالمومنین(علیه السلام) توسط پیامبر اکرم(صلی الله علیه و آله) دین کامل گشت", "خداوند با ابلاغ ولایت و امامت امیرالمومنین(علیه السلام) و یازده فرزند پاکشان از اسلام اعلام رضایت فرمودند", "شرط اینکه دین شخص مسلمان مورد رضایت خداوند متعال قرار گیرد پذیرش ولایت و امامت ائمه (علیهم السلام) است", "امامت از فروع دین بوده و قبول یا عدم پذیرش آن لطمه‌ای به آن شخص وارد نمی‌کند", "با توجه به مطلبی که در آیه شریفه «الْيَوْمَ أَكْمَلْتُ لَكُمْ دِينَكُمْ وَ أَتْمَمْتُ عَلَيْكُمْ نِعْمَتِي وَ رَضِيتُ لَكُمُ الْإِسْلامَ دِينا» در روز غدیر نازل گشته است. کدام گزینه صحیح نمی‌باشد؟" }
});
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DeleteData(
table: "QuizQuestions",
keyColumn: "Id",
keyValue: 4);
migrationBuilder.DeleteData(
table: "QuizQuestions",
keyColumn: "Id",
keyValue: 5);
migrationBuilder.DeleteData(
table: "QuizQuestions",
keyColumn: "Id",
keyValue: 6);
migrationBuilder.DeleteData(
table: "QuizQuestions",
keyColumn: "Id",
keyValue: 7);
migrationBuilder.DeleteData(
table: "QuizQuestions",
keyColumn: "Id",
keyValue: 8);
migrationBuilder.DeleteData(
table: "QuizQuestions",
keyColumn: "Id",
keyValue: 9);
migrationBuilder.DeleteData(
table: "QuizQuestions",
keyColumn: "Id",
keyValue: 10);
migrationBuilder.UpdateData(
table: "QuizQuestions",
keyColumn: "Id",
keyValue: 1,
columns: new[] { "CorrectOption", "Option1", "Option2", "Option3", "Option4", "QuestionText" },
values: new object[] { 1, "سال ۱۰ هجری", "سال ۱۱ هجری", "سال ۹ هجری", "سال ۱۲ هجری", "غدیر در چه سالی واقع شد؟" });
migrationBuilder.UpdateData(
table: "QuizQuestions",
keyColumn: "Id",
keyValue: 2,
columns: new[] { "Option1", "Option2", "Option3", "Option4", "QuestionText" },
values: new object[] { "ابوبکر", "عمر", "علی (ع)", "عثمان", "پیامبر اکرم (ص) در غدیر چه کسی را به عنوان جانشین معرفی کردند؟" });
migrationBuilder.UpdateData(
table: "QuizQuestions",
keyColumn: "Id",
keyValue: 3,
columns: new[] { "CorrectOption", "Option1", "Option2", "Option3", "Option4", "QuestionText" },
values: new object[] { 2, "مسجد النبی", "غدیر خم", "مکه", "مدینه", "خطبه غدیر در کجا ایراد شد؟" });
}
}
}

View File

@@ -0,0 +1,448 @@
// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using backend.Data;
#nullable disable
namespace backend.Migrations
{
[DbContext(typeof(AppDbContext))]
partial class AppDbContextModelSnapshot : ModelSnapshot
{
protected override void BuildModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "8.0.0")
.HasAnnotation("Relational:MaxIdentifierLength", 128);
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
modelBuilder.Entity("backend.Models.KhatmItem", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("Points")
.HasColumnType("int");
b.Property<string>("Title")
.IsRequired()
.HasMaxLength(200)
.HasColumnType("nvarchar(200)");
b.Property<string>("Url")
.HasMaxLength(500)
.HasColumnType("nvarchar(500)");
b.HasKey("Id");
b.ToTable("KhatmItems");
b.HasData(
new
{
Id = 1,
Points = 5,
Title = "ختم نادعلی",
Url = "https://example.com/khatm/nadali"
},
new
{
Id = 2,
Points = 10,
Title = "خطبه غدیر",
Url = "https://example.com/khatm/ghadir"
},
new
{
Id = 3,
Points = 7,
Title = "دعای توسل",
Url = "https://example.com/khatm/tavassol"
});
});
modelBuilder.Entity("backend.Models.QuizQuestion", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("CorrectOption")
.HasColumnType("int");
b.Property<string>("Option1")
.IsRequired()
.HasMaxLength(200)
.HasColumnType("nvarchar(200)");
b.Property<string>("Option2")
.IsRequired()
.HasMaxLength(200)
.HasColumnType("nvarchar(200)");
b.Property<string>("Option3")
.IsRequired()
.HasMaxLength(200)
.HasColumnType("nvarchar(200)");
b.Property<string>("Option4")
.IsRequired()
.HasMaxLength(200)
.HasColumnType("nvarchar(200)");
b.Property<string>("QuestionText")
.IsRequired()
.HasMaxLength(500)
.HasColumnType("nvarchar(500)");
b.HasKey("Id");
b.ToTable("QuizQuestions");
b.HasData(
new
{
Id = 1,
CorrectOption = 3,
Option1 = "در مورد ثمرات ولایت و محبت اهل‌بیت",
Option2 = "در مورد جنبه غضب الهی",
Option3 = "در مورد امام مهدی علیه‌السلام",
Option4 = "اقرار لسانی",
QuestionText = "هشتمین بخش خطبه غدیر در چه موضوعی است؟"
},
new
{
Id = 2,
CorrectOption = 1,
Option1 = "این لقب به دستور مستقیم از جانب خداوند به ایشان داده شد",
Option2 = "پیامبر اکرم، خودشان این لقب را انتخاب کردند",
Option3 = "مردم به علت فضائل بسیار ایشان، این لقب را انتخاب کردند",
Option4 = "به درخواست خود ایشان بود",
QuestionText = "لقب «امیرالمؤمنین» توسط چه کسی به مولا علی علیه‌السلام اطلاق شد؟"
},
new
{
Id = 3,
CorrectOption = 3,
Option1 = "کسانی که خبر اسلام به آنان نرسیده است",
Option2 = "کسانی که در مدیریت زمان ضعیف هستند",
Option3 = "دشمنان آل محمد (صلی‌الله‌علیه‌وآله)",
Option4 = "اهل کتاب",
QuestionText = "طبق فرمایش پیامبر اکرم در غدیر، عبارت «إِنَّ الإِنسَانَ لَفِي خُسْرٍ»، «انسان در زیان است» درباره چه کسانی است؟"
},
new
{
Id = 4,
CorrectOption = 4,
Option1 = "آيه 31 سوره نور",
Option2 = "آيه 58 – 60 سوره نور",
Option3 = "آيه 59 – 60 سوره احزاب",
Option4 = "آيه 59 – 60 سوره نساء",
QuestionText = "كدام يك از آيات زير مربوط به حجاب نمي باشد؟"
},
new
{
Id = 5,
CorrectOption = 3,
Option1 = "پوشش – عفاف",
Option2 = "ترك نظر – پوشش",
Option3 = "ترك نظر – پاكدامني",
Option4 = "پوشش – پاكدامني",
QuestionText = "اين قسمت از آيه 31 سوره نور « قل للمومنات يغضضن من ابصار هن و يحفظن فروجهن» بيانگر كدام دو تكليف است؟"
},
new
{
Id = 6,
CorrectOption = 1,
Option1 = "زنان سالخورده اي كه اميدي به ازدواج ايشان نمي باشد",
Option2 = "بردگان و مملوكان",
Option3 = "طفيلياني كه نيازي به زن ندارند",
Option4 = "اطفال نابالغ ولو مميز نزديك به بلوغ",
QuestionText = "منظور از (( قواعد )) در سوره نور آيات 58-60 چه كساني هستند؟"
},
new
{
Id = 7,
CorrectOption = 3,
Option1 = "سوره کهف آیه ۲۸",
Option2 = "سوره انعام آیه ۶۱",
Option3 = "سوره زمر ۵۶",
Option4 = "سوره طه ۴۵",
QuestionText = "در کدام آیه از قرآن مجید خداوند می فرماید که درباره علی تفریط و کوتاهی نکنید؟"
},
new
{
Id = 8,
CorrectOption = 2,
Option1 = "تعيين امامت ،علی عليه السلام",
Option2 = "تبليغ امامت، علی عليه السلام",
Option3 = "تعيين و تبليغ امامت، علی عليه السلام",
Option4 = "سپردن تعیین امامت به مردم",
QuestionText = "طبق آیه 67 سوره مائده وظيفه رسول خدا در برابر امامت چيست و آيه در شأن چه كسی نازل شده است؟\n«يَا أَيُّهَا الرَّسُولُ بَلِّغْ مَا أُنْزِلَ إِلَيْكَ مِنْ رَبِّكَ وَإِنْ لَمْ تَفْعَلْ فَمَا بَلَّغْتَ رِسَالَتَهُ ...»"
},
new
{
Id = 9,
CorrectOption = 1,
Option1 = "عید غدیر، روز تبلیغ و معرفی امیرالمومنین به عنوان جانشین پیامبر",
Option2 = "روز جمعه",
Option3 = "عید قربان، حج تمتع",
Option4 = "عید فطر، پایان یک ماه بندگی",
QuestionText = "طبق روایت امام رضا علیه السلام برترین عید امت اسلامی کدام است؟"
},
new
{
Id = 10,
CorrectOption = 4,
Option1 = "با ابلاغ ولایت و امامت امیرالمومنین(علیه السلام) توسط پیامبر اکرم(صلی الله علیه و آله) دین کامل گشت",
Option2 = "خداوند با ابلاغ ولایت و امامت امیرالمومنین(علیه السلام) و یازده فرزند پاکشان از اسلام اعلام رضایت فرمودند",
Option3 = "شرط اینکه دین شخص مسلمان مورد رضایت خداوند متعال قرار گیرد پذیرش ولایت و امامت ائمه (علیهم السلام) است",
Option4 = "امامت از فروع دین بوده و قبول یا عدم پذیرش آن لطمه‌ای به آن شخص وارد نمی‌کند",
QuestionText = "با توجه به مطلبی که در آیه شریفه «الْيَوْمَ أَكْمَلْتُ لَكُمْ دِينَكُمْ وَ أَتْمَمْتُ عَلَيْكُمْ نِعْمَتِي وَ رَضِيتُ لَكُمُ الْإِسْلامَ دِينا» در روز غدیر نازل گشته است. کدام گزینه صحیح نمی‌باشد؟"
});
});
modelBuilder.Entity("backend.Models.User", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("Contact")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("nvarchar(50)");
b.Property<string>("FullName")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("nvarchar(100)");
b.Property<string>("TrackingCode")
.IsRequired()
.HasMaxLength(4)
.HasColumnType("nvarchar(4)");
b.HasKey("Id");
b.HasIndex("Contact")
.IsUnique();
b.HasIndex("TrackingCode")
.IsUnique();
b.ToTable("Users");
});
modelBuilder.Entity("backend.Models.UserKhatmSelection", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<bool>("IsSelected")
.HasColumnType("bit");
b.Property<int>("KhatmItemId")
.HasColumnType("int");
b.Property<DateTime>("LastModified")
.HasColumnType("datetime2");
b.Property<int>("UserId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("KhatmItemId");
b.HasIndex("UserId", "KhatmItemId")
.IsUnique();
b.ToTable("UserKhatmSelections");
});
modelBuilder.Entity("backend.Models.UserQuizAnswer", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<bool>("IsCorrect")
.HasColumnType("bit");
b.Property<int>("QuestionId")
.HasColumnType("int");
b.Property<int>("SelectedOption")
.HasColumnType("int");
b.Property<int>("UserQuizAttemptId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("QuestionId");
b.HasIndex("UserQuizAttemptId");
b.ToTable("UserQuizAnswers");
});
modelBuilder.Entity("backend.Models.UserQuizAttempt", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<DateTime>("CompletedAt")
.HasColumnType("datetime2");
b.Property<int>("CorrectAnswersCount")
.HasColumnType("int");
b.Property<int>("ParticipationPoints")
.HasColumnType("int");
b.Property<int>("TotalQuizPoints")
.HasColumnType("int");
b.Property<int>("UserId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("UserId")
.IsUnique();
b.ToTable("UserQuizAttempts");
});
modelBuilder.Entity("backend.Models.UserTotalScore", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("TotalPoints")
.HasColumnType("int");
b.Property<int>("UserId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("UserId")
.IsUnique();
b.ToTable("UserTotalScores");
});
modelBuilder.Entity("backend.Models.UserKhatmSelection", b =>
{
b.HasOne("backend.Models.KhatmItem", "KhatmItem")
.WithMany("UserSelections")
.HasForeignKey("KhatmItemId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("backend.Models.User", "User")
.WithMany("KhatmSelections")
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("KhatmItem");
b.Navigation("User");
});
modelBuilder.Entity("backend.Models.UserQuizAnswer", b =>
{
b.HasOne("backend.Models.QuizQuestion", "Question")
.WithMany("Answers")
.HasForeignKey("QuestionId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("backend.Models.UserQuizAttempt", "QuizAttempt")
.WithMany("Answers")
.HasForeignKey("UserQuizAttemptId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Question");
b.Navigation("QuizAttempt");
});
modelBuilder.Entity("backend.Models.UserQuizAttempt", b =>
{
b.HasOne("backend.Models.User", "User")
.WithOne("QuizAttempt")
.HasForeignKey("backend.Models.UserQuizAttempt", "UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("User");
});
modelBuilder.Entity("backend.Models.UserTotalScore", b =>
{
b.HasOne("backend.Models.User", "User")
.WithOne("TotalScore")
.HasForeignKey("backend.Models.UserTotalScore", "UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("User");
});
modelBuilder.Entity("backend.Models.KhatmItem", b =>
{
b.Navigation("UserSelections");
});
modelBuilder.Entity("backend.Models.QuizQuestion", b =>
{
b.Navigation("Answers");
});
modelBuilder.Entity("backend.Models.User", b =>
{
b.Navigation("KhatmSelections");
b.Navigation("QuizAttempt");
b.Navigation("TotalScore");
});
modelBuilder.Entity("backend.Models.UserQuizAttempt", b =>
{
b.Navigation("Answers");
});
#pragma warning restore 612, 618
}
}
}