Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions TransactionProcessor.BusinessLogic/Services/FloatDomainService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,19 @@

public static class DomainServiceHelper
{
public static async Task<Result<TAggregate>> GetAggregateOrFailure<TAggregate>(Func<CancellationToken, Task<Result<TAggregate>>> fetchFunc,
Guid aggregateId,
CancellationToken cancellationToken,
Boolean isNotFoundError = true) where TAggregate : Aggregate, new()

Check warning on line 192 in TransactionProcessor.BusinessLogic/Services/FloatDomainService.cs

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

TransactionProcessor.BusinessLogic/Services/FloatDomainService.cs#L192

Use the overloading mechanism instead of the optional parameters.
{
Result<TAggregate> result = await fetchFunc(cancellationToken);
return result.IsFailed switch

Check notice on line 195 in TransactionProcessor.BusinessLogic/Services/FloatDomainService.cs

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

TransactionProcessor.BusinessLogic/Services/FloatDomainService.cs#L195

Replace this 'switch' expression with a ternary conditional operator to increase readability.
{
true => DomainServiceHelper.HandleGetAggregateResult(result, aggregateId, isNotFoundError),
_ => Result.Success(result.Data)
};
}

public static Result<T> HandleGetAggregateResult<T>(Result<T> result, Guid aggregateId, bool isNotFoundError = true)
where T : Aggregate, new() // Constraint: T is a subclass of Aggregate and has a parameterless constructor
{
Expand Down
Loading
Loading