< Summary - Estud

Information
Class: Estud.Back.Features.Periods.CreateEnrollmentPeriod.CreateEnrollmentPeriodService
Assembly: Back
File(s): /home/runner/work/syki/syki/Back/Features/Periods/CreateEnrollmentPeriod/CreateEnrollmentPeriodService.cs
Tag: 114_29044117136
Line coverage
100%
Covered lines: 10
Uncovered lines: 0
Coverable lines: 10
Total lines: 23
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/Periods/CreateEnrollmentPeriod/CreateEnrollmentPeriodService.cs

#LineLine coverage
 1using Estud.Back.Domain.Periods;
 2
 3namespace Estud.Back.Features.Periods.CreateEnrollmentPeriod;
 4
 145public class CreateEnrollmentPeriodService(EstudDbContext ctx) : IEstudService
 6{
 7    public async Task<OneOf<CreateEnrollmentPeriodOut, EstudError>> Create(CreateEnrollmentPeriodIn data)
 8    {
 149        var institutionId = ctx.RequestUser.InstitutionId;
 10
 1411        var result = EnrollmentPeriod.New(institutionId, data.Name, data.StartAt, data.EndAt);
 1812        if (result.IsError) return result.Error;
 13
 1014        var period = result.Success;
 15
 1016        var periodExists = await ctx.EnrollmentPeriods.AnyAsync(p => p.InstitutionId == institutionId && p.Name == perio
 1217        if (periodExists) return EnrollmentPeriodAlreadyExists.I;
 18
 819        await ctx.SaveChangesAsync(period);
 20
 821        return new CreateEnrollmentPeriodOut { Id = period.Id };
 1422    }
 23}