< Summary

Information
Class: Syki.Back.Features.Student.GetStudentEnrollmentClasses.GetStudentEnrollmentClassesService
Assembly: Back
File(s): /home/runner/work/syki/syki/Back/Features/Student/GetStudentEnrollmentClasses/GetStudentEnrollmentClassesService.cs
Tag: 22_11348620282
Line coverage
100%
Covered lines: 35
Uncovered lines: 0
Coverable lines: 35
Total lines: 47
Line coverage: 100%
Branch coverage
100%
Covered branches: 2
Total branches: 2
Branch coverage: 100%
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()100%22100%

File(s)

/home/runner/work/syki/syki/Back/Features/Student/GetStudentEnrollmentClasses/GetStudentEnrollmentClassesService.cs

#LineLine coverage
 1namespace Syki.Back.Features.Student.GetStudentEnrollmentClasses;
 2
 73public class GetStudentEnrollmentClassesService(SykiDbContext ctx) : IStudentService
 4{
 5    public async Task<List<EnrollmentClassOut>> Get(Guid institutionId, Guid userId, Guid courseCurriculumId)
 6    {
 77        var today = DateOnly.FromDateTime(DateTime.Now);
 78        var enrollmentPeriod = await ctx.EnrollmentPeriods.AsNoTracking()
 79            .Where(p => p.InstitutionId == institutionId && p.StartAt <= today && p.EndAt >= today)
 710            .FirstOrDefaultAsync();
 11
 712        if (enrollmentPeriod == null)
 413            return [];
 14
 315        var courseCurriculum = await ctx.CourseCurriculums.Where(g => g.Id == courseCurriculumId).AsNoTracking()
 316            .Include(g => g.Links)
 317            .FirstAsync();
 3918        var ids = courseCurriculum.Links.ConvertAll(d => d.DisciplineId);
 19
 320        var classes = await ctx.Classes.AsNoTracking()
 321            .Include(t => t.Discipline)
 322            .Include(t => t.Schedules)
 323            .Include(t => t.Teacher)
 324            .Where(t => t.InstitutionId == institutionId && t.PeriodId == enrollmentPeriod.Id && t.Status == ClassStatus
 325            .ToListAsync();
 26
 327        var selecteds = await ctx.ClassesStudents.Where(x => x.SykiStudentId == userId).Select(x => x.ClassId).ToListAsy
 28
 329        var response = classes.ConvertAll(t =>
 330        {
 3331            var link = courseCurriculum.Links.First(v => v.DisciplineId == t.DisciplineId);
 432            return new EnrollmentClassOut
 433            {
 434                Id = t.Id,
 435                Discipline = t.Discipline.Name,
 436                Period = link.Period,
 437                Credits = link.Credits,
 438                Workload = link.Workload,
 439                Teacher = t.Teacher.Name,
 440                Schedules = t.Schedules.ConvertAll(h => h.ToOut()),
 441                IsSelected = selecteds.Contains(t.Id),
 442            };
 343        });
 44
 745        return response.OrderBy(t => t.Period).ToList();
 746    }
 47}