< Summary - Syki

Information
Class: Syki.Back.Features.Teacher.CreateClassActivity.CreateClassActivityCreatedWebhookCallCommand
Assembly: Back
File(s): /home/runner/work/syki/syki/Back/Features/Teacher/CreateClassActivity/CreateClassActivityCreatedWebhookCallCommand.cs
Tag: 4_16869239191
Line coverage
0%
Covered lines: 0
Uncovered lines: 1
Coverable lines: 1
Total lines: 33
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/Teacher/CreateClassActivity/CreateClassActivityCreatedWebhookCallCommand.cs

#LineLine coverage
 1using Syki.Back.Features.Academic.CallWebhooks;
 2
 3namespace Syki.Back.Features.Teacher.CreateClassActivity;
 4
 5[CommandDescription("Criar chamada de webhook para o evento 'Atividade publicada'")]
 06public record CreateClassActivityCreatedWebhookCallCommand(DomainEventId EventId, Guid WebhookId, Guid ClassActivityId) 
 7
 8public class CreateClassActivityCreatedWebhookCallCommandHandler(SykiDbContext ctx) : ICommandHandler<CreateClassActivit
 9{
 10    public async Task Handle(CommandId commandId, CreateClassActivityCreatedWebhookCallCommand command)
 11    {
 12        var activity = await ctx.ClassActivities
 13            .Where(x => x.Id == command.ClassActivityId)
 14            .Select(x => new { x.Id, x.Title, x.Type })
 15            .FirstAsync();
 16
 17        var webhook = await ctx.Webhooks
 18            .Include(x => x.Authentication)
 19            .Where(x => x.Id == command.WebhookId)
 20            .Select(x => new { x.InstitutionId, x.Authentication.ApiKey })
 21            .FirstAsync();
 22
 23        var payload = new ClassActivityCreatedWebhookPayload(activity.Id, activity.Title, activity.Type);
 24        var call = new WebhookCall(
 25            webhook.InstitutionId,
 26            command.WebhookId,
 27            payload,
 28            command.EventId,
 29            WebhookEventType.ClassActivityCreated
 30        );
 31        ctx.Add(call);
 32    }
 33}

Methods/Properties

get_EventId()