< Summary

Information
Class: Syki.Back.Features.Student.CreateStudentEnrollment.CreateStudentEnrollmentService
Assembly: Back
File(s): /home/runner/work/syki/syki/Back/Features/Student/CreateStudentEnrollment/CreateStudentEnrollmentService.cs
Tag: 22_11348620282
Line coverage
100%
Covered lines: 20
Uncovered lines: 0
Coverable lines: 20
Total lines: 30
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%
Create()100%22100%

File(s)

/home/runner/work/syki/syki/Back/Features/Student/CreateStudentEnrollment/CreateStudentEnrollmentService.cs

#LineLine coverage
 1namespace Syki.Back.Features.Student.CreateStudentEnrollment;
 2
 3043public class CreateStudentEnrollmentService(SykiDbContext ctx) : IStudentService
 4{
 5    public async Task<OneOf<SykiSuccess, SykiError>> Create(Guid institutionId, Guid userId, Guid courseCurriculumId, Cr
 6    {
 387        var today = DateOnly.FromDateTime(DateTime.Now);
 388        var enrollmentPeriod = await ctx.EnrollmentPeriods.AsNoTracking()
 389            .Where(p => p.InstitutionId == institutionId && p.StartAt <= today && p.EndAt >= today)
 3810            .FirstOrDefaultAsync();
 3911        if (enrollmentPeriod == null) return new EnrollmentPeriodNotFound();
 12
 3713        var courseCurriculum = await ctx.CourseCurriculums.Where(g => g.Id == courseCurriculumId).AsNoTracking()
 3714            .Include(g => g.Links)
 3715            .FirstAsync();
 48116        var disciplines = courseCurriculum.Links.ConvertAll(d => d.DisciplineId);
 3717        var classes = await ctx.Classes.AsNoTracking()
 3718            .Where(t => t.InstitutionId == institutionId && t.PeriodId == enrollmentPeriod.Id && t.Status == ClassStatus
 3719            .ToListAsync();
 35720        var ids = classes.Where(t => data.Classes.Contains(t.Id)).Select(t => t.Id).ToList();
 21
 3722        var classesStudents = await ctx.ClassesStudents.Where(x => x.SykiStudentId == userId && x.StudentDisciplineStatu
 3723        ctx.RemoveRange(classesStudents);
 19624        ids.ForEach(id => ctx.Add(new ClassStudent(id, userId)));
 25
 3726        await ctx.SaveChangesAsync();
 27
 3728        return new SykiSuccess();
 3829    }
 30}