< Summary

Information
Class: Syki.Back.Features.Academic.CreateEnrollmentPeriod.CreateEnrollmentPeriodService
Assembly: Back
File(s): /home/runner/work/syki/syki/Back/Features/Academic/CreateEnrollmentPeriod/CreateEnrollmentPeriodService.cs
Tag: 22_11348620282
Line coverage
100%
Covered lines: 12
Uncovered lines: 0
Coverable lines: 12
Total lines: 23
Line coverage: 100%
Branch coverage
100%
Covered branches: 6
Total branches: 6
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%66100%

File(s)

/home/runner/work/syki/syki/Back/Features/Academic/CreateEnrollmentPeriod/CreateEnrollmentPeriodService.cs

#LineLine coverage
 1namespace Syki.Back.Features.Academic.CreateEnrollmentPeriod;
 2
 3293public class CreateEnrollmentPeriodService(SykiDbContext ctx) : IAcademicService
 4{
 5    public async Task<OneOf<EnrollmentPeriodOut, SykiError>> Create(Guid institutionId, CreateEnrollmentPeriodIn data)
 6    {
 637        var academicPeriodExists = await ctx.AcademicPeriodExists(institutionId, data.Id);
 648        if (!academicPeriodExists) return new AcademicPeriodNotFound();
 9
 6210        var enrollmentPeriodExists = await ctx.EnrollmentPeriods.AnyAsync(x => x.InstitutionId == institutionId && x.Id 
 6311        if (enrollmentPeriodExists) return new EnrollmentPeriodAlreadyExists();
 12
 6113        var result = EnrollmentPeriod.New(data.Id, institutionId, data.StartAt, data.EndAt);
 14
 6315        if (result.IsError()) return result.GetError();
 16
 5917        var period = result.GetSuccess();
 5918        ctx.Add(period);
 5919        await ctx.SaveChangesAsync();
 20
 5921        return period.ToOut();
 6322    }
 23}