Ignore:
Timestamp:
10/27/25 21:50:02 (11 months ago)
Author:
stefansaveski <stefansaveski19@…>
Branches:
master
Children:
e423ff3
Parents:
4f5d8fd
Message:

Add user-related entities and enforce one-to-one mappings

Enhanced the User model with new entities: ContactInfo,
EnrollmentInfo, and HighSchool, establishing one-to-one
relationships. Updated UserDTO with additional fields and
introduced enums for type, quota, and major. Modified
UserRepository and AuthService to handle new entities.

Updated database schema with unique constraints on UserId
for related tables and added EF Core migration
20251027191028_dbRelations. Adjusted JSON serialization
to prevent circular references.

Location:
iknow-api/Repository
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • iknow-api/Repository/Implementations/UserRepository.cs

    r4f5d8fd rc0256f3  
    2525        }
    2626       
    27         public async Task<User> GetUserByIdAsync(int id)
     27        public async Task<User?> GetUserByIdAsync(int id)
    2828        {
    29             return await _context.User.FirstOrDefaultAsync(u => u.Id == id);
     29            return await _context.User
     30                .Include(u => u.ContactInfo)
     31                .Include(u => u.EnrollmentInfo)
     32                .Include(u => u.HighSchool)
     33                .FirstOrDefaultAsync(u => u.Id == id);
    3034        }
    3135
     
    3640            await _context.SaveChangesAsync();
    3741        }
     42        public async Task AddContactAsync(ContactInfo contactInfo)
     43        {
     44            _context.ContactInfo.Add(contactInfo);
     45            await _context.SaveChangesAsync();
     46        }
     47        public async Task AddEnrollmentAsync(EnrollmentInfo enrollment)
     48        {
     49            _context.EnrollmentInfo.Add(enrollment);
     50            await _context.SaveChangesAsync();
     51        }   
     52        public async Task AddHighSchoolAsync(HighSchool highSchool)
     53        {
     54            _context.HighSchool.Add(highSchool);
     55            await _context.SaveChangesAsync();
     56        }       
    3857
    3958        public async Task<int> GetUsersCountAsync()
  • iknow-api/Repository/Interface/IUserRepository.cs

    r4f5d8fd rc0256f3  
    77        Task<User?> GetUserByUsernameAsync(string username);
    88        Task AddUserAsync(User user);
     9        Task AddContactAsync(ContactInfo contactInfo);
     10        Task AddEnrollmentAsync(EnrollmentInfo enrollment);
     11        Task AddHighSchoolAsync(HighSchool highSchool);
    912        Task<int> GetUsersCountAsync();
    1013        Task<User> GetUserByIdAsync(int id);
Note: See TracChangeset for help on using the changeset viewer.