< Summary - Estud

Information
Class: Estud.Back.Features.Students.GetStudent.GetStudentService
Assembly: Back
File(s): /home/runner/work/syki/syki/Back/Features/Students/GetStudent/GetStudentService.cs
Tag: 114_29044117136
Line coverage
100%
Covered lines: 20
Uncovered lines: 0
Coverable lines: 20
Total lines: 30
Line coverage: 100%
Branch coverage
75%
Covered branches: 3
Total branches: 4
Branch coverage: 75%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)100%11100%
Get()75%44100%

File(s)

/home/runner/work/syki/syki/Back/Features/Students/GetStudent/GetStudentService.cs

#LineLine coverage
 1namespace Estud.Back.Features.Students.GetStudent;
 2
 43public class GetStudentService(EstudDbContext ctx) : IEstudService
 4{
 5    public async Task<OneOf<GetStudentOut, EstudError>> Get(int studentId)
 6    {
 47        var institutionId = ctx.RequestUser.InstitutionId;
 8
 49        var student = await ctx.Students.AsNoTracking()
 410            .Include(s => s.User)
 411            .FirstOrDefaultAsync(s => s.Id == studentId && s.InstitutionId == institutionId);
 12
 613        if (student == null) return StudentNotFound.I;
 14
 215        var currentEnrollment = await ctx.StudentCourseEnrollments.AsNoTracking()
 216            .Where(e => e.StudentId == studentId && e.LeftAt == null)
 217            .OrderByDescending(e => e.EnrolledAt)
 218            .FirstOrDefaultAsync();
 19
 220        return new GetStudentOut
 221        {
 222            Id = student.Id,
 223            Name = student.Name,
 224            Email = student.User!.Email!,
 225            EnrollmentCode = student.EnrollmentCode,
 226            Status = student.Status,
 227            CurrentCourseOfferingId = currentEnrollment?.CourseOfferingId,
 228        };
 429    }
 30}