< Summary - Syki

Information
Class: Syki.Back.Features.Adm.ReprocessCommand.ReprocessCommandService
Assembly: Back
File(s): /home/runner/work/syki/syki/Back/Features/Adm/ReprocessCommand/ReprocessCommandService.cs
Tag: 4_16869239191
Line coverage
0%
Covered lines: 0
Uncovered lines: 14
Coverable lines: 14
Total lines: 28
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%
Reprocess()0%4260%

File(s)

/home/runner/work/syki/syki/Back/Features/Adm/ReprocessCommand/ReprocessCommandService.cs

#LineLine coverage
 1using Newtonsoft.Json;
 2
 3namespace Syki.Back.Features.Adm.ReprocessCommand;
 4
 05public class ReprocessCommandService(SykiDbContext ctx) : IAdmService
 6{
 7    public async Task<OneOf<SykiSuccess, SykiError>> Reprocess(CommandId id)
 8    {
 09        var command = await ctx.Commands.AsNoTracking().FirstOrDefaultAsync(x => x.Id == id);
 10
 011        if (command is null) return new CommandNotFound();
 12
 013        if (command.OriginalId != null) return new OnlyRootCommandsCanBeReprocessed();
 14
 015        var type = typeof(DomainEvent).Assembly.GetType(command.Type)!;
 016        dynamic data = JsonConvert.DeserializeObject(command.Data, type)!;
 17
 018        var newCommand = new Command(command.InstitutionId, data, originalId: command.Id)
 019        {
 020            Type = command.Type,
 021        };
 22
 023        ctx.Commands.Add(newCommand);
 024        await ctx.SaveChangesAsync();
 25
 026        return new SykiSuccess();
 027    }
 28}