Add JobExceptionHandlingBehavior and improve mappings
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.
This commit is contained in:
@@ -2,6 +2,7 @@ using AutoMapper;
|
||||
using ECMJobRunner.Application.Common.Dtos;
|
||||
using ECMJobRunner.Domain.Interfaces;
|
||||
using MediatR;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
@@ -58,12 +59,23 @@ namespace ECMJobRunner.Application.Profiles.Queries
|
||||
private readonly ICfgProfileRepository _profileRepository;
|
||||
private readonly IMapper _mapper;
|
||||
|
||||
/// <summary>
|
||||
/// Constructor
|
||||
/// </summary>
|
||||
/// <param name="profileRepository">Repository for profile data access</param>
|
||||
/// <param name="mapper">AutoMapper instance for entity-to-DTO mapping</param>
|
||||
public GetProfileQueryHandler(ICfgProfileRepository profileRepository, IMapper mapper)
|
||||
{
|
||||
_profileRepository = profileRepository;
|
||||
_mapper = mapper;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handles the <see cref="GetProfileQuery"/> by retrieving and mapping profiles
|
||||
/// </summary>
|
||||
/// <param name="request">The query containing optional filter parameters</param>
|
||||
/// <param name="cancellationToken">Cancellation token</param>
|
||||
/// <returns>List of matched profiles mapped to <see cref="CfgProfileDto"/></returns>
|
||||
public async Task<List<CfgProfileDto>> Handle(GetProfileQuery request, CancellationToken cancellationToken)
|
||||
{
|
||||
IEnumerable<Domain.Entities.CfgProfile> profiles;
|
||||
@@ -112,8 +124,11 @@ namespace ECMJobRunner.Application.Profiles.Queries
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(request.ProfileName))
|
||||
{
|
||||
var searchName = request.ProfileName.ToLowerInvariant();
|
||||
profiles = profiles.Where(p => p.ProfileName.ToLowerInvariant().Contains(searchName));
|
||||
#if NET
|
||||
profiles = profiles.Where(p => p.ProfileName.Contains(request.ProfileName, StringComparison.OrdinalIgnoreCase));
|
||||
#else
|
||||
profiles = profiles.Where(p => p.ProfileName.IndexOf(request.ProfileName!, StringComparison.OrdinalIgnoreCase) >= 0);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user