< Summary - Syki

Information
Class: Syki.Back.Features.Cross.SeedInstitutionData.SeedInstitutionUsersCommandHandler
Assembly: Back
File(s): /home/runner/work/syki/syki/Back/Features/Cross/SeedInstitutionData/SeedInstitutionUsersCommand.cs
Tag: 4_16869239191
Line coverage
0%
Covered lines: 0
Uncovered lines: 36
Coverable lines: 36
Total lines: 58
Line coverage: 0%
Branch coverage
0%
Covered branches: 0
Total branches: 6
Branch coverage: 0%
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()0%4260%

File(s)

/home/runner/work/syki/syki/Back/Features/Cross/SeedInstitutionData/SeedInstitutionUsersCommand.cs

#LineLine coverage
 1using Syki.Back.Features.Academic.CreateStudent;
 2using Syki.Back.Features.Academic.CreateTeacher;
 3
 4namespace Syki.Back.Features.Cross.SeedInstitutionData;
 5
 6[CommandDescription("Realizar seed de usuários da instituição")]
 7public record SeedInstitutionUsersCommand(Guid InstitutionId, Guid DireitoCourseOfferingId, Guid AdsCourseOfferingId) : 
 8
 09public class SeedInstitutionUsersCommandHandler(
 010    SykiDbContext ctx,
 011    CreateTeacherService createTeacherService,
 012    CreateStudentService createStudentService) : ICommandHandler<SeedInstitutionUsersCommand>
 13{
 14    public async Task Handle(CommandId commandId, SeedInstitutionUsersCommand command)
 15    {
 016        var id = command.InstitutionId;
 17
 018        var teachers = new List<string>()
 019        {
 020            "Davi Pessoa Ferraz",
 021            "Luciete Bezerra Alves",
 022            "Manuela Abath Valença",
 023            "Paulo Marcelo Pedrosa de Almeida",
 024        };
 025        foreach (var name in teachers)
 26        {
 027            await createTeacherService.CreateWithThrowOnError(id, CreateTeacherIn.Seed(name));
 28        }
 29
 030        var direitoStudents = new List<string>()
 031        {
 032            "Alisson Aranda de Aguiar",
 033            "Maria Júlia de Oliveira Melo",
 034            "Everton Ian de Galhardo Filho",
 035            "Alma Celeste Maldonado Mendonça",
 036        };
 037        foreach (var name in direitoStudents)
 38        {
 039            await createStudentService.CreateWithThrowOnError(id, CreateStudentIn.Seed(name, command.DireitoCourseOfferi
 40        }
 41
 042        var adsStudents = new List<string>()
 043        {
 044            "Simone Bezerra",
 045            "Marcelo Lima Filho",
 046            "Josilda Aragão Paz",
 047            "Marlene de Oliveira",
 048            "Miguel Gomes da Silva",
 049            "Zaqueu do Vale Cavalcante",
 050        };
 051        foreach (var name in adsStudents)
 52        {
 053            await createStudentService.CreateWithThrowOnError(id, CreateStudentIn.Seed(name, command.AdsCourseOfferingId
 54        }
 55
 056        ctx.AddCommand(id, new SeedInstitutionClassesCommand(id), parentId: commandId);
 057    }
 58}