< Summary - Syki

Information
Class: Syki.Back.Features.Student.CreateClassActivityWork.CreateNewStudentClassNoteNotificationCommand
Assembly: Back
File(s): /home/runner/work/syki/syki/Back/Features/Student/CreateClassActivityWork/CreateNewStudentClassNoteNotificationCommand.cs
Tag: 4_16869239191
Line coverage
100%
Covered lines: 1
Uncovered lines: 0
Coverable lines: 1
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
get_ClassActivityId()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")]
 2646public record CreateNewStudentClassNoteNotificationCommand(Guid ClassActivityId, Guid UserId) : ICommand;
 7
 8public class CreateNewStudentClassNoteNotificationCommandHandler(SykiDbContext ctx) : ICommandHandler<CreateNewStudentCl
 9{
 10    public async Task Handle(CommandId commandId, CreateNewStudentClassNoteNotificationCommand command)
 11    {
 12        var activity = await ctx.ClassActivities
 13            .Where(x => x.Id == command.ClassActivityId)
 14            .Select(x => new { x.ClassId, x.Title })
 15            .FirstAsync();
 16
 17        var institutionId = await ctx.Classes
 18            .Where(x => x.Id == activity.ClassId)
 19            .Select(x => x.InstitutionId)
 20            .FirstAsync();
 21
 22        var notification = new Notification(
 23            institutionId,
 24            "Nota adicionada",
 25            $"Confira sua nota na atividade: {activity.Title}",
 26            UsersGroup.Students,
 27            false
 28        );
 29
 30        ctx.AddRange(notification, new UserNotification(command.UserId, notification.Id));
 31    }
 32}

Methods/Properties

get_ClassActivityId()