initial commit from an older template

This commit is contained in:
2025-09-20 22:33:35 +03:00
commit b6778046c2
134 changed files with 6657 additions and 0 deletions

50
Database/ApplicationContext.cs Executable file
View File

@@ -0,0 +1,50 @@
using GamificationService.Models.Database;
using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore;
namespace GamificationService.Database;
public class ApplicationContext : IdentityDbContext<ApplicationUser, ApplicationRole, long>
{
public ApplicationContext(DbContextOptions<ApplicationContext> options) : base(options)
{
}
public DbSet<Right> Rights { get; set; }
public DbSet<RefreshToken> RefreshTokens { get; set; }
public DbSet<ApplicationUser> Users { get; set; }
public DbSet<ApplicationRole> Roles { get; set; }
public DbSet<UserRole> UserRoles { get; set; }
public DbSet<RoleRight> RoleRights { get; set; }
public DbSet<UserProfile> UserProfiles { get; set; }
public DbSet<Instruction> Instructions { get; set; }
public DbSet<InstructionCategory> InstructionCategories { get; set; }
public DbSet<InstructionParagraph> InstructionParagraphs { get; set; }
public DbSet<InstructionTest> InstructionTests { get; set; }
public DbSet<InstructionTestQuestion> InstructionTestQuestions { get; set; }
public DbSet<InstructionTestResult> InstructionTestResults { get; set; }
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
modelBuilder.Entity<UserRole>()
.HasKey(ur => new { ur.UserId, ur.RoleId });
modelBuilder.Entity<RoleRight>()
.HasKey(rr => new { rr.RoleId, rr.RightId });
modelBuilder.Entity<InstructionTest>()
.HasMany(itq => itq.Questions);
modelBuilder.Entity<InstructionTestResult>()
.HasOne(itr => itr.InstructionTest);
modelBuilder.Entity<Instruction>()
.HasOne(i => i.Category);
modelBuilder.Entity<Instruction>()
.HasMany(i => i.Paragraphs);
}
}