< Summary

Information
Class: Syki.Back.Features.Teacher.GetTeacherLessonAttendances.GetTeacherLessonAttendancesService
Assembly: Back
File(s): /home/runner/work/syki/syki/Back/Features/Teacher/GetTeacherLessonAttendances/GetTeacherLessonAttendancesService.cs
Tag: 22_11348620282
Line coverage
0%
Covered lines: 0
Uncovered lines: 16
Coverable lines: 16
Total lines: 25
Line coverage: 0%
Branch coverage
0%
Covered branches: 0
Total branches: 6
Branch coverage: 0%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)100%210%
Get()0%2040%

File(s)

/home/runner/work/syki/syki/Back/Features/Teacher/GetTeacherLessonAttendances/GetTeacherLessonAttendancesService.cs

#LineLine coverage
 1namespace Syki.Back.Features.Teacher.GetTeacherLessonAttendances;
 2
 03public class GetTeacherLessonAttendancesService(SykiDbContext ctx) : ITeacherService
 4{
 5    public async Task<OneOf<List<GetTeacherLessonAttendanceOut>, SykiError>> Get(Guid institutionId, Guid userId, Guid l
 6    {
 07        var lesson = await ctx.Lessons.FirstOrDefaultAsync(x => x.Id == lessonId);
 08        if (lesson == null) return new LessonNotFound();
 9
 010        var @class = await ctx.Classes.AsNoTracking()
 011            .Include(x => x.Students)
 012            .Where(t => t.InstitutionId == institutionId && t.TeacherId == userId && t.Id == lesson.ClassId)
 013            .FirstOrDefaultAsync();
 14
 015        if (@class == null) return new ClassNotFound();
 16
 017        var attendances = await ctx.Attendances.Where(x => x.LessonId == lessonId).ToListAsync();
 018        return @class.Students.OrderBy(s => s.Name).Select(s =>
 019        {
 020            var value = attendances.FirstOrDefault(a => a.StudentId == s.Id);
 021            if (value != null) return value.ToOut(s.Name);
 022            return new() { LessonId = lessonId, StudentId = s.Id, StudentName = s.Name };
 023        }).ToList();
 024    }
 25}