Refactor: move OutResults to Results namespace

Refactored all "Result" related command and query classes from ReC.Application.OutResults to ReC.Application.Results. Updated all relevant using statements and reorganized files accordingly. No functional changes; this improves project structure and clarity.
This commit is contained in:
2026-01-16 11:13:06 +01:00
parent 36fe78e152
commit 4895b9c8f8
8 changed files with 9 additions and 9 deletions

View File

@@ -0,0 +1,32 @@
using ReC.Application.Common.Procedures.DeleteProcedure;
namespace ReC.Application.Results.Commands;
public record DeleteResultProcedure : IDeleteProcedure
{
/// <summary>
/// Start GUID/ID (inclusive)
/// </summary>
public long Start { get; set; }
/// <summary>
/// End GUID/ID (inclusive). If 0, will be set to Start value.
/// </summary>
public long End { get; set; }
/// <summary>
/// Force parameter (not used for RESULT entity as it has no dependencies)
/// </summary>
public bool Force { get; set; }
public DeleteObjectProcedure ToObjectProcedure()
{
return new DeleteObjectProcedure
{
Entity = "RESULT",
Start = Start,
End = End,
Force = Force
};
}
}

View File

@@ -0,0 +1,20 @@
using ReC.Application.Common.Procedures.InsertProcedure;
namespace ReC.Application.Results.Commands;
public record InsertResultProcedure : IInsertProcedure
{
public long? ActionId { get; set; }
public short? StatusId { get; set; }
public string? Header { get; set; }
public string? Body { get; set; }
public InsertObjectProcedure ToObjectProcedure(string? addedWho = null)
{
return new InsertObjectProcedure
{
Entity = "RESULT",
Result = this
}.AddedBy(addedWho ?? "Rec.API");
}
}

View File

@@ -0,0 +1,21 @@
using ReC.Application.Common.Procedures.UpdateProcedure;
namespace ReC.Application.Results.Commands;
public record UpdateResultProcedure : IUpdateProcedure
{
public long? ActionId { get; set; }
public short? StatusId { get; set; }
public string? Header { get; set; }
public string? Body { get; set; }
public UpdateObjectProcedure ToObjectProcedure(long id, string? changedWho = null)
{
return new UpdateObjectProcedure
{
Entity = "RESULT",
Id = id,
Result = this
}.ChangedBy(changedWho);
}
}

View File

@@ -0,0 +1,49 @@
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.Views;
using System.Text.Json;
namespace ReC.Application.Results.Queries;
public record ReadResultViewQuery : IRequest<IEnumerable<ResultViewDto>>
{
public long? Id { get; init; } = null;
public long? ActionId { get; init; } = null;
public long? ProfileId { get; init; } = null;
}
public class ReadResultViewQueryHandler(IRepository<ResultView> repo, IMapper mapper) : IRequestHandler<ReadResultViewQuery, IEnumerable<ResultViewDto>>
{
public async Task<IEnumerable<ResultViewDto>> Handle(ReadResultViewQuery request, CancellationToken cancel)
{
var q = repo.Query;
if(request.Id is long id)
q = q.Where(rv => rv.Id == id);
if(request.ActionId is long actionId)
q = q.Where(rv => rv.ActionId == actionId);
if(request.ProfileId is long profileId)
q = q.Where(rv => rv.ProfileId == profileId);
var entities = await q.ToListAsync(cancel);
if (entities.Count == 0)
throw new NotFoundException($"No result views found for the given criteria. Criteria: {
JsonSerializer.Serialize(request, options: new()
{
PropertyNamingPolicy = JsonNamingPolicy.CamelCase,
WriteIndented = true
})}"
);
return mapper.Map<IEnumerable<ResultViewDto>>(entities);
}
}