< Summary

Information
Class: Elsa.Persistence.EFCore.Modules.Labels.EFCoreLabelStore
Assembly: Elsa.Persistence.EFCore
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Persistence.EFCore/Modules/Labels/LabelStore.cs
Line coverage
0%
Covered lines: 0
Uncovered lines: 21
Coverable lines: 21
Total lines: 60
Line coverage: 0%
Branch coverage
0%
Covered branches: 0
Total branches: 2
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%
SaveAsync()100%210%
SaveManyAsync()100%210%
DeleteAsync()100%210%
DeleteManyAsync()100%210%
FindByIdAsync()100%210%
ListAsync()0%620%
FindManyByIdAsync()100%210%

File(s)

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Persistence.EFCore/Modules/Labels/LabelStore.cs

#LineLine coverage
 1using Elsa.Common.Models;
 2using Elsa.Labels.Contracts;
 3using Elsa.Labels.Entities;
 4using Elsa.Persistence.EFCore.Extensions;
 5
 6namespace Elsa.Persistence.EFCore.Modules.Labels;
 7
 8/// <summary>
 9/// An Entity Framework Core implementation of <see cref="ILabelStore"/>.
 10/// </summary>
 11public class EFCoreLabelStore : ILabelStore
 12{
 13    private readonly EntityStore<LabelsElsaDbContext, Label> _labelStore;
 14    private readonly EntityStore<LabelsElsaDbContext, WorkflowDefinitionLabel> _workflowDefinitionLabelStore;
 15
 16    /// <summary>
 17    /// Initializes a new instance of <see cref="EFCoreLabelStore"/>.
 18    /// </summary>
 019    public EFCoreLabelStore(EntityStore<LabelsElsaDbContext, Label> labelStore, EntityStore<LabelsElsaDbContext, Workflo
 20    {
 021        _labelStore = labelStore;
 022        _workflowDefinitionLabelStore = workflowDefinitionLabelStore;
 023    }
 24
 25    /// <inheritdoc />
 026    public async Task SaveAsync(Label record, CancellationToken cancellationToken = default) => await _labelStore.SaveAs
 27
 28    /// <inheritdoc />
 029    public async Task SaveManyAsync(IEnumerable<Label> records, CancellationToken cancellationToken = default) => await 
 30
 31    /// <inheritdoc />
 32    public async Task<bool> DeleteAsync(string id, CancellationToken cancellationToken = default)
 33    {
 034        await _workflowDefinitionLabelStore.DeleteWhereAsync(x => x.LabelId == id, cancellationToken);
 035        return await _labelStore.DeleteWhereAsync(x => x.Id == id, cancellationToken) > 0;
 036    }
 37
 38    /// <inheritdoc />
 39    public async Task<long> DeleteManyAsync(IEnumerable<string> ids, CancellationToken cancellationToken = default)
 40    {
 041        var idList = ids.ToList();
 042        await _workflowDefinitionLabelStore.DeleteWhereAsync(x => idList.Contains(x.LabelId), cancellationToken);
 043        return await _labelStore.DeleteWhereAsync(x => idList.Contains(x.Id), cancellationToken);
 044    }
 45
 046    public async Task<Label?> FindByIdAsync(string id, CancellationToken cancellationToken = default) => await _labelSto
 47
 48    public async Task<Page<Label>> ListAsync(PageArgs? pageArgs = null, CancellationToken cancellationToken = default)
 49    {
 050        await using var dbContext = await _labelStore.CreateDbContextAsync(cancellationToken);
 051        var set = dbContext.Labels.OrderBy(x => x.Name);
 052        return await set.PaginateAsync(pageArgs);
 053    }
 54
 55    public async Task<IEnumerable<Label>> FindManyByIdAsync(IEnumerable<string> ids, CancellationToken cancellationToken
 56    {
 057        var idList = ids.ToList();
 058        return await _labelStore.FindManyAsync(x => idList.Contains(x.Id), cancellationToken);
 059    }
 60}