Added [Obsolete] attribute to "fake" Get methods in OutResController, as well as to ReadOutResQuery, ReadOutResHandler, and ReadOutResQueryValidator. These components are now deprecated in favor of related procedures or views. No functional changes were made.
39 lines
1.2 KiB
C#
39 lines
1.2 KiB
C#
using AutoMapper;
|
|
using DigitalData.Core.Abstraction.Application.Repository;
|
|
using DigitalData.Core.Exceptions;
|
|
using MediatR;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using ReC.Application.Common.Dto;
|
|
using ReC.Domain.Entities;
|
|
|
|
namespace ReC.Application.OutResults.Queries;
|
|
|
|
[Obsolete("Use the related procedure or view.")]
|
|
public record ReadOutResQuery : IRequest<IEnumerable<OutResDto>>
|
|
{
|
|
public long? ProfileId { get; init; }
|
|
|
|
public long? ActionId { get; init; }
|
|
}
|
|
|
|
[Obsolete("Use the related procedure or view.")]
|
|
public class ReadOutResHandler(IRepository<OutRes> repo, IMapper mapper) : IRequestHandler<ReadOutResQuery, IEnumerable<OutResDto>>
|
|
{
|
|
public async Task<IEnumerable<OutResDto>> Handle(ReadOutResQuery request, CancellationToken cancel)
|
|
{
|
|
var q = repo.Query;
|
|
|
|
if(request.ActionId is long actionId)
|
|
q = q.Where(res => res.ActionId == actionId);
|
|
|
|
if(request.ProfileId is long profileId)
|
|
q = q.Where(res => res.Action!.ProfileId == profileId);
|
|
|
|
var resList = await q.ToListAsync(cancel);
|
|
|
|
if (resList.Count == 0)
|
|
throw new NotFoundException();
|
|
|
|
return mapper.Map<IEnumerable<OutResDto>>(resList);
|
|
}
|
|
} |