Ignore:
Timestamp:
12/10/25 13:44:07 (10 months ago)
Author:
Stefan-Saveski <stefansaveski19@…>
Branches:
master
Children:
33c69d6
Parents:
2d64b2e
Message:

Add getSemesters endpoint and related data access

Introduce a new getSemesters endpoint in UserController.cs to retrieve user semester data using JWT authentication.

Add DbSet<EnrolledSemesters> to AppDbContext.cs for database interaction.

Implement GetUserSemestersAsync in UserRepository.cs to fetch semesters by user ID, and update IUserRepository.cs to declare this method.

Add GetUserSemesters method in UserService.cs to extract user ID from JWT and retrieve semesters, updating IUserService.cs accordingly.

File:
1 edited

Legend:

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

    r2d64b2e r691f152  
    3333            else
    3434                return user;
     35        }
     36        public async Task<List<EnrolledSemesters>> GetUserSemesters(string JWT)
     37        {
     38            var userId = ExtractUserIdFromJwt(JWT);
     39            if (userId == null)
     40                return null;
     41
     42            // Now you can use userId to fetch user data
     43            var semesters = await _userRepository.GetUserSemestersAsync(userId.Value);
     44            if (semesters == null)
     45                return null;
     46            else
     47                return semesters;
    3548        }
    3649
Note: See TracChangeset for help on using the changeset viewer.