Add CloseAsync method to WorkflowRepository

Introduced a new asynchronous method `CloseAsync` in the
`WorkflowRepository` class to handle workflow process closing.
This method executes the `PRCUST_F19_CLOSING` stored procedure
with parameters for user ID, source, process ID, closing method
ID, comment, and rejection reason ID. It uses `FromSqlInterpolated`
for safe SQL parameterization and retrieves results with
`AsNoTracking()` and `ToListAsync(cancellationToken)`. The method
returns the first result as a `WorkflowClosing` object or `null`.
This commit is contained in:
2026-11-03 20:44:08 +01:00
parent ca3772e2a8
commit 210c1f414c

View File

@@ -19,4 +19,35 @@ public sealed class WorkflowRepository(TaskFlowDbContext context) : IWorkflowRep
return rows.FirstOrDefault();
}
public async Task<WorkflowClosing?> CloseAsync(
int userId,
string source,
long processId,
int closingMethodId,
string? comment,
byte? rejectionReasonId,
CancellationToken cancellationToken)
{
var rows = await context.WorkflowClosings
.FromSqlInterpolated($@"
DECLARE @ResultCode INT;
DECLARE @ResultMessage NVARCHAR(400);
EXEC dbo.PRCUST_F19_CLOSING
@UserID = {userId},
@Source = {source},
@ProcessID = {processId},
@ClosingMethodID = {closingMethodId},
@Comment = {comment},
@RejectionReasonID = {rejectionReasonId},
@ResultCode = @ResultCode OUTPUT,
@ResultMessage = @ResultMessage OUTPUT;
SELECT @ResultCode AS CODE, @ResultMessage AS RESULT;")
.AsNoTracking()
.ToListAsync(cancellationToken);
return rows.FirstOrDefault();
}
}