< Summary - Syki

Information
Class: Syki.Back.Features.Student.CreateClassActivityWork.CreateNewStudentClassNoteNotificationCommandHandler
Assembly: Back
File(s): /home/runner/work/syki/syki/Back/Features/Student/CreateClassActivityWork/CreateNewStudentClassNoteNotificationCommand.cs
Tag: 4_16869239191
Line coverage
100%
Covered lines: 18
Uncovered lines: 0
Coverable lines: 18
Total lines: 32
Line coverage: 100%
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%11100%
Handle()100%11100%

File(s)

/home/runner/work/syki/syki/Back/Features/Student/CreateClassActivityWork/CreateNewStudentClassNoteNotificationCommand.cs

#LineLine coverage
 1using Syki.Back.Features.Academic.CreateNotification;
 2
 3namespace Syki.Back.Features.Student.CreateClassActivityWork;
 4
 5[CommandDescription("Criar notificação de nota adicionada")]
 6public record CreateNewStudentClassNoteNotificationCommand(Guid ClassActivityId, Guid UserId) : ICommand;
 7
 448public class CreateNewStudentClassNoteNotificationCommandHandler(SykiDbContext ctx) : ICommandHandler<CreateNewStudentCl
 9{
 10    public async Task Handle(CommandId commandId, CreateNewStudentClassNoteNotificationCommand command)
 11    {
 4412        var activity = await ctx.ClassActivities
 4413            .Where(x => x.Id == command.ClassActivityId)
 4414            .Select(x => new { x.ClassId, x.Title })
 4415            .FirstAsync();
 16
 4417        var institutionId = await ctx.Classes
 4418            .Where(x => x.Id == activity.ClassId)
 4419            .Select(x => x.InstitutionId)
 4420            .FirstAsync();
 21
 4422        var notification = new Notification(
 4423            institutionId,
 4424            "Nota adicionada",
 4425            $"Confira sua nota na atividade: {activity.Title}",
 4426            UsersGroup.Students,
 4427            false
 4428        );
 29
 4430        ctx.AddRange(notification, new UserNotification(command.UserId, notification.Id));
 4431    }
 32}