Ignore:
Timestamp:
10/27/25 21:50:02 (11 months ago)
Author:
stefansaveski <stefansaveski19@…>
Branches:
master
Children:
ff202cf
Parents:
cab02ad
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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • iknow-api/Services/Implementations/AuthService.cs

    rcab02ad rb38c39c  
    4040
    4141            await _userRepository.AddUserAsync(user);
     42            int userId = user.Id;
     43            var contactInfo = new ContactInfo
     44            {
     45                UserId = userId,
     46                city = registerDto.city,
     47                address = registerDto.address,
     48                municipality = registerDto.municipality,
     49                phoneNumber = registerDto.phoneNumber,
     50                microsoftEmail = registerDto.microsoftEmail
     51            };
     52            await _userRepository.AddContactAsync(contactInfo);
     53            var enrollmentInfo = new EnrollmentInfo
     54            {
     55                UserId = userId,
     56                enrollmentYear = registerDto.enrollmentYear,
     57                quota = (Models.quota)registerDto.quotaType,
     58                major = (Models.major)registerDto.majorType
     59            };
     60            await _userRepository.AddEnrollmentAsync(enrollmentInfo);
     61            await _userRepository.AddHighSchoolAsync(new HighSchool
     62            {
     63                UserId = userId,
     64                GPA = registerDto.gpa,
     65                tip = (Models.type)registerDto.tip
     66            });
    4267            return true;
    4368        }
Note: See TracChangeset for help on using the changeset viewer.