Skip to content

Commit

Permalink
Merge pull request #26 from bsandmann/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
ndigirigijohn authored Feb 15, 2025
2 parents 350c1e0 + 2ce3568 commit 9303c17
Show file tree
Hide file tree
Showing 10 changed files with 1,189 additions and 718 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
namespace Blocktrust.CredentialWorkflow.Core.Commands.WorkflowOutcome.GetWorkflowOutcomeById;

using Blocktrust.CredentialWorkflow.Core.Domain.ProcessFlow.Actions;
using Domain.Workflow;
using FluentResults;
using MediatR;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,33 +1,32 @@
namespace Blocktrust.CredentialWorkflow.Core.Commands.WorkflowOutcome.GetWorkflowOutcomeIdsByState
namespace Blocktrust.CredentialWorkflow.Core.Commands.WorkflowOutcome.GetWorkflowOutcomeIdsByState;

using FluentResults;
using MediatR;
using Microsoft.EntityFrameworkCore;

public class GetWorkflowOutcomeIdsByStateHandler
: IRequestHandler<GetWorkflowOutcomeIdsByStateRequest, Result<List<GetWorkflowOutcomeIdsByStateResponse>>>
{
using FluentResults;
using MediatR;
using Microsoft.EntityFrameworkCore;
private readonly DataContext _context;

public class GetWorkflowOutcomeIdsByStateHandler
: IRequestHandler<GetWorkflowOutcomeIdsByStateRequest, Result<List<GetWorkflowOutcomeIdsByStateResponse>>>
public GetWorkflowOutcomeIdsByStateHandler(DataContext context)
{
private readonly DataContext _context;

public GetWorkflowOutcomeIdsByStateHandler(DataContext context)
{
_context = context;
}
_context = context;
}

public async Task<Result<List<GetWorkflowOutcomeIdsByStateResponse>>> Handle(
GetWorkflowOutcomeIdsByStateRequest request,
CancellationToken cancellationToken)
{
var outcomes = await _context.WorkflowOutcomeEntities
.Where(o => request.WorkflowOutcomeStates.Contains(o.WorkflowOutcomeState))
.Select(o => new GetWorkflowOutcomeIdsByStateResponse
{
OutcomeId = o.WorkflowOutcomeEntityId,
WorkflowOutcomeState = o.WorkflowOutcomeState
})
.ToListAsync(cancellationToken);
public async Task<Result<List<GetWorkflowOutcomeIdsByStateResponse>>> Handle(
GetWorkflowOutcomeIdsByStateRequest request,
CancellationToken cancellationToken)
{
var outcomes = await _context.WorkflowOutcomeEntities
.Where(o => request.WorkflowOutcomeStates.Contains(o.WorkflowOutcomeState))
.Select(o => new GetWorkflowOutcomeIdsByStateResponse
{
OutcomeId = o.WorkflowOutcomeEntityId,
WorkflowOutcomeState = o.WorkflowOutcomeState
})
.ToListAsync(cancellationToken);

return Result.Ok(outcomes);
}
return Result.Ok(outcomes);
}
}
Original file line number Diff line number Diff line change
@@ -1,36 +1,35 @@
namespace Blocktrust.CredentialWorkflow.Core.Commands.WorkflowOutcome.UpdateWorkflowOutcomeState
namespace Blocktrust.CredentialWorkflow.Core.Commands.WorkflowOutcome.UpdateWorkflowOutcomeState;

using FluentResults;
using MediatR;
using Microsoft.EntityFrameworkCore;

public class UpdateWorkflowOutcomeStateHandler : IRequestHandler<UpdateWorkflowOutcomeStateRequest, Result>
{
using FluentResults;
using MediatR;
using Microsoft.EntityFrameworkCore;
private readonly DataContext _context;

public class UpdateWorkflowOutcomeStateHandler : IRequestHandler<UpdateWorkflowOutcomeStateRequest, Result>
public UpdateWorkflowOutcomeStateHandler(DataContext context)
{
private readonly DataContext _context;
_context = context;
}

public UpdateWorkflowOutcomeStateHandler(DataContext context)
{
_context = context;
}
public async Task<Result> Handle(UpdateWorkflowOutcomeStateRequest request, CancellationToken cancellationToken)
{
// Retrieve the outcome from the database
var outcomeEntity = await _context.WorkflowOutcomeEntities
.FirstOrDefaultAsync(o => o.WorkflowOutcomeEntityId == request.WorkflowOutcomeId, cancellationToken);

public async Task<Result> Handle(UpdateWorkflowOutcomeStateRequest request, CancellationToken cancellationToken)
if (outcomeEntity is null)
{
// Retrieve the outcome from the database
var outcomeEntity = await _context.WorkflowOutcomeEntities
.FirstOrDefaultAsync(o => o.WorkflowOutcomeEntityId == request.WorkflowOutcomeId, cancellationToken);

if (outcomeEntity is null)
{
return Result.Fail("The specified outcome does not exist in the database.");
}
return Result.Fail("The specified outcome does not exist in the database.");
}

// Update the state
outcomeEntity.WorkflowOutcomeState = request.NewState;
// Update the state
outcomeEntity.WorkflowOutcomeState = request.NewState;

// Save changes to the database
await _context.SaveChangesAsync(cancellationToken);
// Save changes to the database
await _context.SaveChangesAsync(cancellationToken);

return Result.Ok();
}
return Result.Ok();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,6 @@ public enum EWorkflowState
Inactive,
ActiveWithExternalTrigger,
ActiveWithRecurrentTrigger,
ActiveWithFormTrigger

}
Loading

0 comments on commit 9303c17

Please sign in to comment.