< Summary

Information
Class: Syki.Back.Features.Cross.FinishUserRegister.FinishUserRegisterService
Assembly: Back
File(s): /home/runner/work/syki/syki/Back/Features/Cross/FinishUserRegister/FinishUserRegisterService.cs
Tag: 22_11348620282
Line coverage
100%
Covered lines: 19
Uncovered lines: 0
Coverable lines: 19
Total lines: 38
Line coverage: 100%
Branch coverage
100%
Covered branches: 6
Total branches: 6
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%
Finish()100%66100%

File(s)

/home/runner/work/syki/syki/Back/Features/Cross/FinishUserRegister/FinishUserRegisterService.cs

#LineLine coverage
 1using Syki.Back.Features.Cross.CreateUser;
 2using Syki.Back.Features.Cross.CreateInstitution;
 3
 4namespace Syki.Back.Features.Cross.FinishUserRegister;
 5
 2916public class FinishUserRegisterService(SykiDbContext ctx, CreateUserService service) : ICrossService
 7{
 8    public async Task<OneOf<UserOut, SykiError>> Finish(FinishUserRegisterIn data)
 9    {
 29110        await using var transaction = await ctx.Database.BeginTransactionAsync();
 11
 29112        _ = Guid.TryParse(data.Token, out var id);
 29113        var register = await ctx.UserRegisters.FirstOrDefaultAsync(d => d.Id == id);
 30214        if (register == null) return new InvalidRegistrationToken();
 15
 28016        var finish = register.Finish();
 28117        if (finish.IsError()) return finish.GetError();
 18
 27919        var institution = new Institution(register.Email.OnlyNumbers());
 27920        ctx.Add(institution);
 21
 27922        ctx.Add(SykiTask.SeedInstitutionData(institution.Id));
 23
 27924        await ctx.SaveChangesAsync();
 25
 27926        var userIn = CreateUserIn.NewAcademic(institution.Id, register.Email, data.Password);
 27927        var result = await service.Create(userIn);
 28
 28729        if (result.IsError()) return result.GetError();
 30
 27131        var user = result.GetSuccess();
 32
 27133        await ctx.SaveChangesAsync();
 27134        await transaction.CommitAsync();
 35
 27136        return user;
 29137    }
 38}