< Summary - Syki

Information
Class: Syki.Back.Features.Students.CreateStudent.CreateStudentService
Assembly: Back
File(s): /home/runner/work/syki/syki/Back/Features/Students/CreateStudent/CreateStudentService.cs
Tag: 56_26538939494
Line coverage
100%
Covered lines: 10
Uncovered lines: 0
Coverable lines: 10
Total lines: 22
Line coverage: 100%
Branch coverage
50%
Covered branches: 1
Total branches: 2
Branch coverage: 50%
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()50%22100%

File(s)

/home/runner/work/syki/syki/Back/Features/Students/CreateStudent/CreateStudentService.cs

#LineLine coverage
 1using Syki.Back.Domain.Identity;
 2using Syki.Back.Domain.Students;
 3
 4namespace Syki.Back.Features.Students.CreateStudent;
 5
 66public class CreateStudentService(SykiDbContext ctx, UserManager<SykiUser> userManager) : ISykiService
 7{
 8    public async Task<OneOf<CreateStudentOut, SykiError>> Create(CreateStudentIn data)
 9    {
 610        var email = data.Email.ToLowerInvariant();
 611        var emailUsed = await ctx.Users.AnyAsync(u => u.Email == email);
 612        if (emailUsed) return EmailAlreadyUsed.I;
 13
 614        var user = new SykiUser(ctx.RequestUser.InstitutionId, data.Name, email);
 615        var student = new SykiStudent(user, ctx.RequestUser.InstitutionId, data.Name);
 616        ctx.Add(student);
 17
 618        await userManager.CreateAsync(user, $"Syki@{Guid.NewGuid()}");
 19
 620        return new CreateStudentOut { Id = student.Id };
 621    }
 22}