< Summary

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

File(s)

/home/runner/work/syki/syki/Back/Features/Academic/CreateTeacher/CreateTeacherService.cs

#LineLine coverage
 1using Syki.Back.Features.Cross.CreateUser;
 2using Syki.Back.Features.Cross.SendResetPasswordToken;
 3
 4namespace Syki.Back.Features.Academic.CreateTeacher;
 5
 3846public class CreateTeacherService(SykiDbContext ctx, CreateUserService service, SendResetPasswordTokenService sendServic
 7{
 8    public async Task<OneOf<TeacherOut, SykiError>> Create(Guid institutionId, CreateTeacherIn data)
 9    {
 11810        await using var transaction = await ctx.Database.BeginTransactionAsync();
 11
 11812        var userIn = CreateUserIn.NewTeacher(institutionId, data.Name, data.Email);
 11813        var result = await service.Create(userIn);
 14
 13615        if (result.IsError()) return result.GetError();
 16
 10017        var user = result.GetSuccess();
 18
 10019        var teacher = new SykiTeacher(user.Id, institutionId, data.Name);
 20
 10021        ctx.Add(teacher);
 10022        ctx.Add(SykiTask.LinkOldNotifications(user.Id, institutionId));
 23
 10024        await sendService.Send(new(user.Email));
 25
 10026        await transaction.CommitAsync();
 27
 10028        return teacher.ToOut();
 11829    }
 30}