< Summary

Information
Class: Syki.Back.Features.Teacher.AddExamGradeNote.AddExamGradeNoteService
Assembly: Back
File(s): /home/runner/work/syki/syki/Back/Features/Teacher/AddExamGradeNote/AddExamGradeNoteService.cs
Tag: 22_11348620282
Line coverage
100%
Covered lines: 11
Uncovered lines: 0
Coverable lines: 11
Total lines: 22
Line coverage: 100%
Branch coverage
83%
Covered branches: 5
Total branches: 6
Branch coverage: 83.3%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)100%11100%
Add()83.33%66100%

File(s)

/home/runner/work/syki/syki/Back/Features/Teacher/AddExamGradeNote/AddExamGradeNoteService.cs

#LineLine coverage
 1namespace Syki.Back.Features.Teacher.AddExamGradeNote;
 2
 3093public class AddExamGradeNoteService(SykiDbContext ctx) : ITeacherService
 4{
 5    public async Task<OneOf<SykiSuccess, SykiError>> Add(Guid teacherId, Guid examGradeId, AddExamGradeNoteIn data)
 6    {
 437        var examGrade = await ctx.ExamGrades.Where(x => x.Id == examGradeId).FirstOrDefaultAsync();
 448        if (examGrade == null) return new ExamGradeNotFound();
 9
 4210        var classOk = await ctx.Classes.AnyAsync(x => x.Id == examGrade.ClassId && x.TeacherId == teacherId);
 4211        if (!classOk) return new TeacherIsNotTheClassLeader();
 12
 4213        var result = examGrade.AddNote(data.Note);
 4414        if (result.IsError()) return result.GetError();
 15
 4016        ctx.Add(SykiTask.CreateNewExamGradeNoteNotification(examGrade.StudentId, examGrade.ClassId));
 17
 4018        await ctx.SaveChangesAsync();
 19
 4020        return new SykiSuccess();
 4321    }
 22}