< Summary

Information
Class: Syki.Back.Features.Academic.CreateCourseCurriculum.CreateCourseCurriculumService
Assembly: Back
File(s): /home/runner/work/syki/syki/Back/Features/Academic/CreateCourseCurriculum/CreateCourseCurriculumService.cs
Tag: 22_11348620282
Line coverage
100%
Covered lines: 23
Uncovered lines: 0
Coverable lines: 23
Total lines: 36
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%44100%

File(s)

/home/runner/work/syki/syki/Back/Features/Academic/CreateCourseCurriculum/CreateCourseCurriculumService.cs

#LineLine coverage
 1namespace Syki.Back.Features.Academic.CreateCourseCurriculum;
 2
 2273public class CreateCourseCurriculumService(SykiDbContext ctx) : IAcademicService
 4{
 5    public async Task<OneOf<CourseCurriculumOut, SykiError>> Create(Guid institutionId, CreateCourseCurriculumIn data)
 6    {
 2277        var courseOk = await ctx.Courses
 2278            .AnyAsync(c => c.InstitutionId == institutionId && c.Id == data.CourseId);
 2299        if (!courseOk) return new CourseNotFound();
 10
 22511        var disciplines = await ctx.CoursesDisciplines.AsNoTracking()
 22512            .Where(x => x.CourseId == data.CourseId)
 22513            .Select(x => x.DisciplineId)
 22514            .ToListAsync();
 15
 199216        if (!data.Disciplines.ConvertAll(d => d.Id).IsSubsetOf(disciplines))
 417            return new InvalidDisciplinesList();
 18
 22119        var courseCurriculum = new CourseCurriculum(institutionId, data.CourseId, data.Name);
 20
 22121        data.Disciplines.ForEach(d =>
 175822            courseCurriculum.Links.Add(new(d.Id, d.Period, d.Credits, d.Workload))
 22123        );
 24
 22125        ctx.Add(courseCurriculum);
 22126        await ctx.SaveChangesAsync();
 27
 22128        courseCurriculum = await ctx.CourseCurriculums.AsNoTracking()
 22129            .Include(g => g.Course)
 22130            .Include(x => x.Disciplines)
 22131            .Include(g => g.Links)
 22132            .FirstAsync(x => x.Id == courseCurriculum.Id);
 33
 22134        return courseCurriculum.ToOut();
 22735    }
 36}