Changeset c2f79d7 for iknow-api/Data


Ignore:
Timestamp:
12/08/25 21:51:12 (10 months ago)
Author:
Stefan-Saveski <stefan@…>
Branches:
master
Children:
bb656bc
Parents:
a92a2a4
Message:

Refactor and enhance application structure

Enhanced error handling in AuthController with detailed exception handling for user registration. Updated UserDTO to improve JSON serialization and renamed enums for clarity. Introduced new entities (Major, PassedSubject, etc.) and seeded initial data in AppDbContext.

Replaced legacy migrations with 20251208203846_InitialCreate, reflecting the updated schema. Fixed typographical errors and improved JSON serialization in Program.cs with case-insensitive property matching and enum handling.

Refactored repository interfaces for better null safety. Improved debugging in AuthService and updated connection strings. Added the PassedSubject entity and cleaned up redundant code and unused imports for better maintainability.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • iknow-api/Data/AppDbContext.cs

    ra92a2a4 rc2f79d7  
    1717        public DbSet<Subject> Subjects { get; set; }
    1818        public DbSet<DependencySubject> DependencySubjects { get; set; }
     19        public DbSet<Major> Majors { get; set; }
     20        public DbSet<PassedSubject> PassedSubjects { get; set; }
    1921
    2022
     
    2224        {
    2325            base.OnModelCreating(modelBuilder);
     26
     27            modelBuilder.Entity<Major>().HasData(
     28                new Major { Id = 1, Name = "PIT" },
     29                new Major { Id = 2, Name = "SIIS" },
     30                new Major { Id = 3, Name = "SEIS" },
     31                new Major { Id = 4, Name = "KN" }
     32            );
     33
    2434
    2535            // -------------------------
     
    128138                .HasForeignKey(ss => ss.EnrolledSemesterId)
    129139                .OnDelete(DeleteBehavior.Restrict);
     140
     141            // -------------------------
     142            // PassedSubject (one-to-one with SemesterSubject)
     143            // -------------------------
     144            modelBuilder.Entity<PassedSubject>()
     145                .HasKey(ps => ps.Id);
     146
     147            modelBuilder.Entity<PassedSubject>()
     148                .HasOne(ps => ps.SemesterSubject)
     149                .WithOne(ss => ss.PassedSubject)
     150                .HasForeignKey<PassedSubject>(ps => ps.SemesterSubjectId)
     151                .OnDelete(DeleteBehavior.Cascade);
    130152        }
    131153
Note: See TracChangeset for help on using the changeset viewer.