< Summary

Information
Class: Syki.Back.Features.Academic.CreateAcademicPeriod.CreateAcademicPeriodService
Assembly: Back
File(s): /home/runner/work/syki/syki/Back/Features/Academic/CreateAcademicPeriod/CreateAcademicPeriodService.cs
Tag: 22_11348620282
Line coverage
100%
Covered lines: 10
Uncovered lines: 0
Coverable lines: 10
Total lines: 20
Line coverage: 100%
Branch coverage
100%
Covered branches: 4
Total branches: 4
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/CreateAcademicPeriod/CreateAcademicPeriodService.cs

#LineLine coverage
 1namespace Syki.Back.Features.Academic.CreateAcademicPeriod;
 2
 2513public class CreateAcademicPeriodService(SykiDbContext ctx) : IAcademicService
 4{
 5    public async Task<OneOf<AcademicPeriodOut, SykiError>> Create(Guid institutionId, CreateAcademicPeriodIn data)
 6    {
 2517        var result = AcademicPeriod.New(data.Id, institutionId, data.StartAt, data.EndAt);
 2668        if (result.IsError()) return result.GetError();
 9
 23610        var period = result.GetSuccess();
 11
 23612        var periodExists = await ctx.AcademicPeriods.AnyAsync(p => p.InstitutionId == institutionId && p.Id == period.Id
 23713        if (periodExists) return new AcademicPeriodAlreadyExists();
 14
 23515        ctx.Add(period);
 23516        await ctx.SaveChangesAsync();
 17
 23518        return period.ToOut();
 25119    }
 20}