< Summary - Syki

Information
Class: Syki.Back.Features.Teacher.CreateClassActivity.CreateClassActivityCreatedWebhookCallCommandHandler
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: 20
Coverable lines: 20
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
.ctor(...)100%210%
Handle()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'")]
 6public record CreateClassActivityCreatedWebhookCallCommand(DomainEventId EventId, Guid WebhookId, Guid ClassActivityId) 
 7
 08public class CreateClassActivityCreatedWebhookCallCommandHandler(SykiDbContext ctx) : ICommandHandler<CreateClassActivit
 9{
 10    public async Task Handle(CommandId commandId, CreateClassActivityCreatedWebhookCallCommand command)
 11    {
 012        var activity = await ctx.ClassActivities
 013            .Where(x => x.Id == command.ClassActivityId)
 014            .Select(x => new { x.Id, x.Title, x.Type })
 015            .FirstAsync();
 16
 017        var webhook = await ctx.Webhooks
 018            .Include(x => x.Authentication)
 019            .Where(x => x.Id == command.WebhookId)
 020            .Select(x => new { x.InstitutionId, x.Authentication.ApiKey })
 021            .FirstAsync();
 22
 023        var payload = new ClassActivityCreatedWebhookPayload(activity.Id, activity.Title, activity.Type);
 024        var call = new WebhookCall(
 025            webhook.InstitutionId,
 026            command.WebhookId,
 027            payload,
 028            command.EventId,
 029            WebhookEventType.ClassActivityCreated
 030        );
 031        ctx.Add(call);
 032    }
 33}