Introduced `JobExceptionHandlingBehavior` to handle exceptions, log errors, and rethrow them during MediatR pipeline execution. Updated `DependencyInjection.cs` to register the new behavior and added a `recClientApiUrl` parameter for API configuration. Enhanced `ProfileMappingProfile.cs` and `GetProfileQuery.cs` with XML documentation for better readability. Improved case-insensitive filtering in `GetProfileQuery` with conditional compilation for .NET version compatibility. Modified `CreateProfileHistoryCommand.cs` to use a non-nullable `AddedWho` property. Added missing `using` directive in `GetProfileQuery.cs` for compatibility. These changes improve code quality, maintainability, and functionality.
61 lines
1.7 KiB
C#
61 lines
1.7 KiB
C#
using ECMJobRunner.Domain.Entities;
|
|
using ECMJobRunner.Domain.Interfaces;
|
|
using ECMJobRunner.Domain.ValueObjects;
|
|
using MediatR;
|
|
using System.Text.Json.Serialization;
|
|
using System.Threading;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace ECMJobRunner.Application.ProfileHistories.Commands
|
|
{
|
|
/// <summary>
|
|
/// Command to create a new profile execution history record
|
|
/// </summary>
|
|
public class CreateProfileHistoryCommand : IRequest<Unit>
|
|
{
|
|
/// <summary>
|
|
/// Foreign key to the related profile
|
|
/// </summary>
|
|
public long ProfileId { get; set; }
|
|
|
|
/// <summary>
|
|
/// Execution result type
|
|
/// </summary>
|
|
public ResultType Result { get; set; }
|
|
|
|
/// <summary>
|
|
/// Result text/message
|
|
/// </summary>
|
|
#if NET
|
|
public required string ResultText { get; set; }
|
|
#else
|
|
|
|
public string ResultText { get; set; } = null!;
|
|
#endif
|
|
|
|
/// <summary>
|
|
/// Created by (max 50 chars)
|
|
/// </summary>
|
|
[JsonIgnore]
|
|
public string AddedWho { get; set; } = null!;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Handler for <see cref="CreateProfileHistoryCommand"/>
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// Constructor
|
|
/// </remarks>
|
|
public class CreateProfileHistoryCommandHandler(IProfileHistoryRepository Repository) : IRequestHandler<CreateProfileHistoryCommand, Unit>
|
|
{
|
|
/// <summary>
|
|
/// Handles the command by persisting a new <see cref="ProfileHistory"/> record
|
|
/// </summary>
|
|
public async Task<Unit> Handle(CreateProfileHistoryCommand request, CancellationToken cancellationToken)
|
|
{
|
|
await Repository.AddAsync(request, cancellationToken);
|
|
return Unit.Value;
|
|
}
|
|
}
|
|
}
|