< Summary - Syki

Information
Class: Syki.Back.Features.Academic.CreateStudent.CreateStudentCreatedWebhookCallCommandHandler
Assembly: Back
File(s): /home/runner/work/syki/syki/Back/Features/Academic/CreateStudent/CreateStudentCreatedWebhookCallCommand.cs
Tag: 4_16869239191
Line coverage
0%
Covered lines: 0
Uncovered lines: 22
Coverable lines: 22
Total lines: 37
Line coverage: 0%
Branch coverage
0%
Covered branches: 0
Total branches: 2
Branch coverage: 0%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)100%210%
Handle()0%620%

File(s)

/home/runner/work/syki/syki/Back/Features/Academic/CreateStudent/CreateStudentCreatedWebhookCallCommand.cs

#LineLine coverage
 1using System.Diagnostics;
 2using Syki.Back.Features.Academic.CallWebhooks;
 3
 4namespace Syki.Back.Features.Academic.CreateStudent;
 5
 6[CommandDescription("Criar chamada de webhook para o evento 'Aluno criado'")]
 7public record CreateStudentCreatedWebhookCallCommand(DomainEventId EventId, Guid WebhookId, Guid UserId) : ICommand;
 8
 09public class CreateStudentCreatedWebhookCallCommandHandler(SykiDbContext ctx) : ICommandHandler<CreateStudentCreatedWebh
 10{
 11    public async Task Handle(CommandId commandId, CreateStudentCreatedWebhookCallCommand command)
 12    {
 013        var activityId = Activity.Current?.Id;
 14
 015        var student = await ctx.Students.AsNoTracking()
 016            .Include(x => x.User)
 017            .Where(x => x.Id == command.UserId)
 018            .Select(x => new { x.Id, x.Name, x.User.Email })
 019            .FirstAsync();
 20
 021        var webhook = await ctx.Webhooks.AsNoTracking()
 022            .Include(x => x.Authentication)
 023            .Where(x => x.Id == command.WebhookId)
 024            .Select(x => new { x.InstitutionId, x.Authentication.ApiKey })
 025            .FirstAsync();
 26
 027        var payload = new StudentCreatedWebhookPayload(student.Id, student.Name, student.Email);
 028        var call = new WebhookCall(
 029            webhook.InstitutionId,
 030            command.WebhookId,
 031            payload,
 032            command.EventId,
 033            WebhookEventType.StudentCreated
 034        );
 035        ctx.Add(call);
 036    }
 37}