< Summary

Information
Class: Elsa.Labels.Services.InMemoryWorkflowDefinitionLabelStore
Assembly: Elsa.Labels
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Labels/Services/InMemoryWorkflowDefinitionLabelStore.cs
Line coverage
0%
Covered lines: 0
Uncovered lines: 26
Coverable lines: 26
Total lines: 94
Line coverage: 0%
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

File(s)

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Labels/Services/InMemoryWorkflowDefinitionLabelStore.cs

#LineLine coverage
 1using Elsa.Common.Services;
 2using Elsa.Labels.Contracts;
 3using Elsa.Labels.Entities;
 4
 5namespace Elsa.Labels.Services;
 6
 7/// <summary>
 8/// An in-memory store of workflow-label associations.
 9/// </summary>
 10public class InMemoryWorkflowDefinitionLabelStore : IWorkflowDefinitionLabelStore
 11{
 12    private readonly MemoryStore<WorkflowDefinitionLabel> _store;
 13
 14    /// <summary>
 15    /// Constructor.
 16    /// </summary>
 017    public InMemoryWorkflowDefinitionLabelStore(MemoryStore<WorkflowDefinitionLabel> store)
 18    {
 019        _store = store;
 020    }
 21
 22    /// <inheritdoc />
 23    public Task SaveAsync(WorkflowDefinitionLabel record, CancellationToken cancellationToken = default)
 24    {
 025        _store.Save(record, x => x.Id);
 026        return Task.CompletedTask;
 27    }
 28
 29    /// <inheritdoc />
 30    public Task SaveManyAsync(IEnumerable<WorkflowDefinitionLabel> records, CancellationToken cancellationToken = defaul
 31    {
 032        _store.SaveMany(records, x => x.Id);
 033        return Task.CompletedTask;
 34    }
 35
 36    /// <inheritdoc />
 37    public Task<bool> DeleteAsync(string id, CancellationToken cancellationToken = default)
 38    {
 039        var result = _store.Delete(id);
 040        return Task.FromResult(result);
 41    }
 42
 43    /// <inheritdoc />
 44    public Task<IEnumerable<WorkflowDefinitionLabel>> FindByWorkflowDefinitionVersionIdAsync(string workflowDefinitionVe
 45    {
 046        var result = _store.FindMany(x => x.WorkflowDefinitionVersionId == workflowDefinitionVersionId);
 047        return Task.FromResult(result);
 48    }
 49
 50    /// <inheritdoc />
 51    public Task ReplaceAsync(IEnumerable<WorkflowDefinitionLabel> removed, IEnumerable<WorkflowDefinitionLabel> added, C
 52    {
 053        _store.DeleteMany(removed, x => x.Id);
 054        _store.SaveMany(added, x => x.Id);
 055        return Task.CompletedTask;
 56    }
 57
 58    /// <inheritdoc />
 59    public Task<long> DeleteByWorkflowDefinitionIdAsync(string workflowDefinitionId, CancellationToken cancellationToken
 60    {
 061        var result = _store.DeleteWhere(x => x.WorkflowDefinitionId == workflowDefinitionId);
 062        return Task.FromResult(result);
 63    }
 64
 65    /// <inheritdoc />
 66    public Task<long> DeleteByWorkflowDefinitionVersionIdAsync(string workflowDefinitionVersionId, CancellationToken can
 67    {
 068        var result = _store.DeleteWhere(x => x.WorkflowDefinitionVersionId == workflowDefinitionVersionId);
 069        return Task.FromResult(result);
 70    }
 71
 72    /// <inheritdoc />
 73    public Task<long> DeleteByWorkflowDefinitionIdsAsync(IEnumerable<string> workflowDefinitionIds, CancellationToken ca
 74    {
 075        var ids = workflowDefinitionIds.ToList();
 076        var result = _store.DeleteWhere(x => ids.Contains(x.WorkflowDefinitionId));
 077        return Task.FromResult(result);
 78    }
 79
 80    /// <inheritdoc />
 81    public Task<long> DeleteByWorkflowDefinitionVersionIdsAsync(IEnumerable<string> workflowDefinitionVersionIds, Cancel
 82    {
 083        var ids = workflowDefinitionVersionIds.ToList();
 084        var result = _store.DeleteWhere(x => ids.Contains(x.WorkflowDefinitionVersionId));
 085        return Task.FromResult(result);
 86    }
 87
 88    private Task<long> DeleteManyAsync(IEnumerable<string> ids, CancellationToken cancellationToken = default)
 89    {
 090        var result = _store.DeleteMany(ids);
 091        return Task.FromResult(result);
 92    }
 93
 94}