< Summary - Syki

Information
Class: Syki.Back.Features.Academic.CreateStudent.CreateStudentCreatedWebhookCallCommand
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: 1
Coverable lines: 1
Total lines: 37
Line coverage: 0%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
get_EventId()100%210%

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'")]
 07public record CreateStudentCreatedWebhookCallCommand(DomainEventId EventId, Guid WebhookId, Guid UserId) : ICommand;
 8
 9public class CreateStudentCreatedWebhookCallCommandHandler(SykiDbContext ctx) : ICommandHandler<CreateStudentCreatedWebh
 10{
 11    public async Task Handle(CommandId commandId, CreateStudentCreatedWebhookCallCommand command)
 12    {
 13        var activityId = Activity.Current?.Id;
 14
 15        var student = await ctx.Students.AsNoTracking()
 16            .Include(x => x.User)
 17            .Where(x => x.Id == command.UserId)
 18            .Select(x => new { x.Id, x.Name, x.User.Email })
 19            .FirstAsync();
 20
 21        var webhook = await ctx.Webhooks.AsNoTracking()
 22            .Include(x => x.Authentication)
 23            .Where(x => x.Id == command.WebhookId)
 24            .Select(x => new { x.InstitutionId, x.Authentication.ApiKey })
 25            .FirstAsync();
 26
 27        var payload = new StudentCreatedWebhookPayload(student.Id, student.Name, student.Email);
 28        var call = new WebhookCall(
 29            webhook.InstitutionId,
 30            command.WebhookId,
 31            payload,
 32            command.EventId,
 33            WebhookEventType.StudentCreated
 34        );
 35        ctx.Add(call);
 36    }
 37}

Methods/Properties

get_EventId()