< Summary

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

#LineLine coverage
 1using Syki.Back.Features.Cross.CreateUser;
 2using Syki.Back.Features.Cross.SendResetPasswordToken;
 3
 4namespace Syki.Back.Features.Academic.CreateStudent;
 5
 3626public class CreateStudentService(SykiDbContext ctx, CreateUserService createService, SendResetPasswordTokenService send
 7{
 8    public async Task<OneOf<StudentOut, SykiError>> Create(Guid institutionId, CreateStudentIn data)
 9    {
 9610        await using var transaction = await ctx.Database.BeginTransactionAsync();
 11
 9612        var courseOfferingExists = await ctx.CourseOfferings
 9613            .AnyAsync(o => o.InstitutionId == institutionId && o.Id == data.CourseOfferingId);
 9714        if (!courseOfferingExists) return new CourseOfferingNotFound();
 15
 9516        var userIn = CreateUserIn.NewStudent(institutionId, data.Name, data.Email, data.PhoneNumber);
 9517        var result = await createService.Create(userIn);
 18
 11319        if (result.IsError()) return result.GetError();
 20
 7721        var user = result.GetSuccess();
 7722        var student = new SykiStudent(user.Id, institutionId, data.Name, data.CourseOfferingId);
 23
 7724        ctx.Add(student);
 7725        ctx.Add(SykiTask.LinkOldNotifications(user.Id, institutionId));
 26
 7727        await sendService.Send(new(user.Email));
 28
 7729        await transaction.CommitAsync();
 30
 7731        return student.ToOut();
 9632    }
 33}