Compare commits
30 Commits
39fcee2b50
...
fb12cb6c98
| Author | SHA1 | Date | |
|---|---|---|---|
| fb12cb6c98 | |||
| 2635bfb223 | |||
| 5245cd04ff | |||
| 9d5334e7dc | |||
| e5bb61376a | |||
| d3aa8c715b | |||
| 6720e66b23 | |||
| 71470fc21d | |||
| 9191ec4179 | |||
| e0d83c0a14 | |||
| 03bcfb6fc9 | |||
| 284ced6059 | |||
| 88c6e6d214 | |||
| 6263848a0a | |||
| 83f173fdc4 | |||
| 7c687c0541 | |||
| 48e9812224 | |||
| 1199c61ae8 | |||
| a55b51e504 | |||
| 752f781f54 | |||
| 9b800dce20 | |||
| 0fa1a418de | |||
| cc54539aba | |||
| ac4c4cb69a | |||
| 73ccb9e43b | |||
| b6ab59ae4a | |||
| 868e11ff62 | |||
| 38d819adac | |||
| 9b3bb925f9 | |||
| a92d57d9cf |
@@ -1,6 +1,7 @@
|
|||||||
using MediatR;
|
using MediatR;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using ReC.API.Extensions;
|
using ReC.API.Extensions;
|
||||||
|
using ReC.API.Models;
|
||||||
using ReC.Application.OutResults.Commands;
|
using ReC.Application.OutResults.Commands;
|
||||||
using ReC.Application.OutResults.Queries;
|
using ReC.Application.OutResults.Queries;
|
||||||
|
|
||||||
@@ -28,6 +29,7 @@ public class OutResController(IMediator mediator, IConfiguration config) : Contr
|
|||||||
/// <returns>A list of output results for the fake profile.</returns>
|
/// <returns>A list of output results for the fake profile.</returns>
|
||||||
[HttpGet("fake")]
|
[HttpGet("fake")]
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
|
[Obsolete("Use the related procedure or view.")]
|
||||||
public async Task<IActionResult> Get(CancellationToken cancel) => Ok(await mediator.Send(new ReadOutResQuery()
|
public async Task<IActionResult> Get(CancellationToken cancel) => Ok(await mediator.Send(new ReadOutResQuery()
|
||||||
{
|
{
|
||||||
ProfileId = config.GetFakeProfileId()
|
ProfileId = config.GetFakeProfileId()
|
||||||
@@ -38,10 +40,11 @@ public class OutResController(IMediator mediator, IConfiguration config) : Contr
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="actionId">The ID of the action to retrieve the result for.</param>
|
/// <param name="actionId">The ID of the action to retrieve the result for.</param>
|
||||||
/// <param name="cancel">A token to cancel the operation.</param>
|
/// <param name="cancel">A token to cancel the operation.</param>
|
||||||
/// <param name="resultType">Specifies which part of the result to return (Full, Header, or Body).</param>
|
/// <param name="resultType">Specifies which part of the result to return (Full, OnlyHeader, or OnlyBody).</param>
|
||||||
/// <returns>The requested output result or a part of it (header/body).</returns>
|
/// <returns>The requested output result or a part of it (header/body).</returns>
|
||||||
[HttpGet("fake/{actionId}")]
|
[HttpGet("fake/{actionId}")]
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
|
[Obsolete("Use the related procedure or view.")]
|
||||||
public async Task<IActionResult> Get([FromRoute] long actionId, CancellationToken cancel, ResultType resultType = ResultType.Full)
|
public async Task<IActionResult> Get([FromRoute] long actionId, CancellationToken cancel, ResultType resultType = ResultType.Full)
|
||||||
{
|
{
|
||||||
var res = (await mediator.Send(new ReadOutResQuery()
|
var res = (await mediator.Send(new ReadOutResQuery()
|
||||||
@@ -52,8 +55,8 @@ public class OutResController(IMediator mediator, IConfiguration config) : Contr
|
|||||||
|
|
||||||
return resultType switch
|
return resultType switch
|
||||||
{
|
{
|
||||||
ResultType.Body => res.Body is null ? Ok(new object { }) : Ok(res.Body.JsonToDynamic()),
|
ResultType.OnlyBody => res.Body is null ? NotFound() : Ok(res.Body.JsonToDynamic()),
|
||||||
ResultType.Header => res.Header is null ? Ok(new object { }) : Ok(res.Header.JsonToDynamic()),
|
ResultType.OnlyHeader => res.Header is null ? NotFound() : Ok(res.Header.JsonToDynamic()),
|
||||||
_ => Ok(res),
|
_ => Ok(res),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -85,23 +88,4 @@ public class OutResController(IMediator mediator, IConfiguration config) : Contr
|
|||||||
await mediator.Send(new DeleteOutResCommand() { ProfileId = config.GetFakeProfileId() }, cancel);
|
await mediator.Send(new DeleteOutResCommand() { ProfileId = config.GetFakeProfileId() }, cancel);
|
||||||
return NoContent();
|
return NoContent();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Defines the type of result to be returned from an output result query.
|
|
||||||
/// </summary>
|
|
||||||
public enum ResultType
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Return the full result object.
|
|
||||||
/// </summary>
|
|
||||||
Full,
|
|
||||||
/// <summary>
|
|
||||||
/// Return only the header part of the result.
|
|
||||||
/// </summary>
|
|
||||||
Header,
|
|
||||||
/// <summary>
|
|
||||||
/// Return only the body part of the result.
|
|
||||||
/// </summary>
|
|
||||||
Body
|
|
||||||
}
|
|
||||||
@@ -3,8 +3,7 @@ using Microsoft.AspNetCore.Mvc;
|
|||||||
using ReC.API.Extensions;
|
using ReC.API.Extensions;
|
||||||
using ReC.API.Models;
|
using ReC.API.Models;
|
||||||
using ReC.Application.RecActions.Commands;
|
using ReC.Application.RecActions.Commands;
|
||||||
using ReC.Application.RecActionViews.Commands;
|
using ReC.Application.RecActions.Queries;
|
||||||
using ReC.Application.RecActionViews.Queries;
|
|
||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
|
|
||||||
namespace ReC.API.Controllers;
|
namespace ReC.API.Controllers;
|
||||||
@@ -73,6 +72,7 @@ public class RecActionController(IMediator mediator, IConfiguration config) : Co
|
|||||||
/// <returns>An HTTP 201 Created response.</returns>
|
/// <returns>An HTTP 201 Created response.</returns>
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
[ProducesResponseType(StatusCodes.Status201Created)]
|
[ProducesResponseType(StatusCodes.Status201Created)]
|
||||||
|
[Obsolete("Use the related procedure.")]
|
||||||
public async Task<IActionResult> CreateAction([FromBody] CreateRecActionCommand command, CancellationToken cancel)
|
public async Task<IActionResult> CreateAction([FromBody] CreateRecActionCommand command, CancellationToken cancel)
|
||||||
{
|
{
|
||||||
await mediator.Send(command, cancel);
|
await mediator.Send(command, cancel);
|
||||||
@@ -91,6 +91,7 @@ public class RecActionController(IMediator mediator, IConfiguration config) : Co
|
|||||||
/// <returns>An HTTP 201 Created response.</returns>
|
/// <returns>An HTTP 201 Created response.</returns>
|
||||||
[HttpPost("fake")]
|
[HttpPost("fake")]
|
||||||
[ProducesResponseType(StatusCodes.Status201Created)]
|
[ProducesResponseType(StatusCodes.Status201Created)]
|
||||||
|
[Obsolete("Use the related procedure.")]
|
||||||
public async Task<IActionResult> CreateFakeAction(
|
public async Task<IActionResult> CreateFakeAction(
|
||||||
CancellationToken cancel,
|
CancellationToken cancel,
|
||||||
[FromBody] FakeRequest? request = null,
|
[FromBody] FakeRequest? request = null,
|
||||||
@@ -126,6 +127,7 @@ public class RecActionController(IMediator mediator, IConfiguration config) : Co
|
|||||||
/// <returns>An HTTP 204 No Content response upon successful deletion.</returns>
|
/// <returns>An HTTP 204 No Content response upon successful deletion.</returns>
|
||||||
[HttpDelete]
|
[HttpDelete]
|
||||||
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
||||||
|
[Obsolete("Use the related procedure.")]
|
||||||
public async Task<IActionResult> Delete([FromQuery] DeleteRecActionsCommand cmd, CancellationToken cancel)
|
public async Task<IActionResult> Delete([FromQuery] DeleteRecActionsCommand cmd, CancellationToken cancel)
|
||||||
{
|
{
|
||||||
await mediator.Send(cmd, cancel);
|
await mediator.Send(cmd, cancel);
|
||||||
@@ -139,6 +141,7 @@ public class RecActionController(IMediator mediator, IConfiguration config) : Co
|
|||||||
/// <returns>An HTTP 204 No Content response upon successful deletion.</returns>
|
/// <returns>An HTTP 204 No Content response upon successful deletion.</returns>
|
||||||
[HttpDelete("fake")]
|
[HttpDelete("fake")]
|
||||||
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
||||||
|
[Obsolete("Use the related procedure.")]
|
||||||
public async Task<IActionResult> Delete(CancellationToken cancel)
|
public async Task<IActionResult> Delete(CancellationToken cancel)
|
||||||
{
|
{
|
||||||
await mediator.Send(new DeleteRecActionsCommand()
|
await mediator.Send(new DeleteRecActionsCommand()
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
using MediatR;
|
using MediatR;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using ReC.API.Extensions;
|
using ReC.API.Extensions;
|
||||||
using ReC.Application.ResultViews.Queries;
|
using ReC.API.Models;
|
||||||
|
using ReC.Application.OutResults.Commands;
|
||||||
|
using ReC.Application.OutResults.Queries;
|
||||||
|
|
||||||
namespace ReC.API.Controllers;
|
namespace ReC.API.Controllers;
|
||||||
|
|
||||||
@@ -32,9 +34,16 @@ public class ResultViewController(IMediator mediator, IConfiguration config) : C
|
|||||||
|
|
||||||
return resultType switch
|
return resultType switch
|
||||||
{
|
{
|
||||||
ResultType.Body => res.Body is null ? Ok(new object { }) : Ok(res.Body.JsonToDynamic()),
|
ResultType.OnlyBody => res.Body is null ? NotFound() : Ok(res.Body.JsonToDynamic()),
|
||||||
ResultType.Header => res.Header is null ? Ok(new object { }) : Ok(res.Header.JsonToDynamic()),
|
ResultType.OnlyHeader => res.Header is null ? NotFound() : Ok(res.Header.JsonToDynamic()),
|
||||||
_ => Ok(res),
|
_ => Ok(res),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
|
public async Task<IActionResult> Create([FromBody] CreateResultViewCommand command, CancellationToken cancel)
|
||||||
|
{
|
||||||
|
await mediator.Send(command, cancel);
|
||||||
|
return CreatedAtAction(nameof(Get), new { actionId = command.ActionId }, command);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
18
src/ReC.API/Middleware/AuthScopedFilter.cs
Normal file
18
src/ReC.API/Middleware/AuthScopedFilter.cs
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
using Microsoft.AspNetCore.Mvc.Filters;
|
||||||
|
using ReC.Application.Common.Interfaces;
|
||||||
|
|
||||||
|
namespace ReC.API.Middleware;
|
||||||
|
|
||||||
|
public class AuthScopedFilter(IConfiguration config) : IAsyncActionFilter
|
||||||
|
{
|
||||||
|
public async Task OnActionExecutionAsync(ActionExecutingContext context, ActionExecutionDelegate next)
|
||||||
|
{
|
||||||
|
if (context.ActionArguments.TryGetValue("command", out var command) && command is IAuthScoped authScopedCommand)
|
||||||
|
{
|
||||||
|
var addedWho = config["AddedWho"] ?? throw new InvalidOperationException("The required 'AddedWho' configuration is missing. Please contact a system administrator.");
|
||||||
|
authScopedCommand.Scope.AddedWho = addedWho;
|
||||||
|
}
|
||||||
|
|
||||||
|
await next();
|
||||||
|
}
|
||||||
|
}
|
||||||
17
src/ReC.API/Models/ResultType.cs
Normal file
17
src/ReC.API/Models/ResultType.cs
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
namespace ReC.API.Models;
|
||||||
|
|
||||||
|
public enum ResultType
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Return the full result object.
|
||||||
|
/// </summary>
|
||||||
|
Full,
|
||||||
|
/// <summary>
|
||||||
|
/// Return only the header part of the result.
|
||||||
|
/// </summary>
|
||||||
|
OnlyHeader,
|
||||||
|
/// <summary>
|
||||||
|
/// Return only the body part of the result.
|
||||||
|
/// </summary>
|
||||||
|
OnlyBody
|
||||||
|
}
|
||||||
@@ -54,7 +54,10 @@ try
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
builder.Services.AddControllers();
|
builder.Services.AddControllers(options =>
|
||||||
|
{
|
||||||
|
options.Filters.Add<AuthScopedFilter>();
|
||||||
|
});
|
||||||
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
|
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
|
||||||
builder.Services.AddEndpointsApiExplorer();
|
builder.Services.AddEndpointsApiExplorer();
|
||||||
builder.Services.AddSwaggerGen(c =>
|
builder.Services.AddSwaggerGen(c =>
|
||||||
|
|||||||
@@ -1,30 +1,29 @@
|
|||||||
using FluentValidation;
|
using FluentValidation;
|
||||||
using MediatR;
|
using MediatR;
|
||||||
|
|
||||||
namespace ReC.Application.Common.Behaviors
|
namespace ReC.Application.Common.Behaviors;
|
||||||
|
|
||||||
|
public class ValidationBehavior<TRequest, TResponse>(IEnumerable<IValidator<TRequest>> validators) : IPipelineBehavior<TRequest, TResponse>
|
||||||
|
where TRequest : notnull
|
||||||
{
|
{
|
||||||
public class ValidationBehavior<TRequest, TResponse>(IEnumerable<IValidator<TRequest>> validators) : IPipelineBehavior<TRequest, TResponse>
|
public async Task<TResponse> Handle(TRequest request, RequestHandlerDelegate<TResponse> next, CancellationToken cancel)
|
||||||
where TRequest : notnull
|
|
||||||
{
|
{
|
||||||
public async Task<TResponse> Handle(TRequest request, RequestHandlerDelegate<TResponse> next, CancellationToken cancel)
|
if (validators.Any())
|
||||||
{
|
{
|
||||||
if (validators.Any())
|
var context = new ValidationContext<TRequest>(request);
|
||||||
{
|
|
||||||
var context = new ValidationContext<TRequest>(request);
|
|
||||||
|
|
||||||
var validationResults = await Task.WhenAll(
|
var validationResults = await Task.WhenAll(
|
||||||
validators.Select(v =>
|
validators.Select(v =>
|
||||||
v.ValidateAsync(context, cancel)));
|
v.ValidateAsync(context, cancel)));
|
||||||
|
|
||||||
var failures = validationResults
|
var failures = validationResults
|
||||||
.SelectMany(r => r.Errors)
|
.SelectMany(r => r.Errors)
|
||||||
.Where(f => f != null)
|
.Where(f => f != null)
|
||||||
.ToList();
|
.ToList();
|
||||||
|
|
||||||
if (failures.Count != 0)
|
if (failures.Count != 0)
|
||||||
throw new ValidationException(failures);
|
throw new ValidationException(failures);
|
||||||
}
|
|
||||||
return await next(cancel);
|
|
||||||
}
|
}
|
||||||
|
return await next(cancel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
using ReC.Domain.Entities;
|
using ReC.Domain.Entities;
|
||||||
|
using ReC.Domain.Views;
|
||||||
|
|
||||||
namespace ReC.Application.Common.Dto;
|
namespace ReC.Application.Common.Dto;
|
||||||
|
|
||||||
|
|||||||
13
src/ReC.Application/Common/Interfaces/IAuthScoped.cs
Normal file
13
src/ReC.Application/Common/Interfaces/IAuthScoped.cs
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
using System.Text.Json.Serialization;
|
||||||
|
|
||||||
|
namespace ReC.Application.Common.Interfaces;
|
||||||
|
|
||||||
|
public record AuthScope
|
||||||
|
{
|
||||||
|
public string? AddedWho { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public interface IAuthScoped : IScoped<AuthScope>
|
||||||
|
{
|
||||||
|
public string? AddedWho => Scope.AddedWho;
|
||||||
|
}
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using ReC.Domain.Entities;
|
using ReC.Domain.Entities;
|
||||||
|
using ReC.Domain.Views;
|
||||||
|
|
||||||
namespace ReC.Application.Common.Interfaces;
|
namespace ReC.Application.Common.Interfaces;
|
||||||
|
|
||||||
|
|||||||
10
src/ReC.Application/Common/Interfaces/IScoped.cs
Normal file
10
src/ReC.Application/Common/Interfaces/IScoped.cs
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
using MediatR;
|
||||||
|
using System.Text.Json.Serialization;
|
||||||
|
|
||||||
|
namespace ReC.Application.Common.Interfaces;
|
||||||
|
|
||||||
|
public interface IScoped<TScope> where TScope : notnull
|
||||||
|
{
|
||||||
|
[JsonIgnore]
|
||||||
|
public TScope Scope { get; }
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
using FluentValidation;
|
||||||
|
using ReC.Application.Common.Interfaces;
|
||||||
|
|
||||||
|
namespace ReC.Application.Common.Validations;
|
||||||
|
|
||||||
|
public class AuthScopedValidator : AbstractValidator<IAuthScoped>
|
||||||
|
{
|
||||||
|
public AuthScopedValidator()
|
||||||
|
{
|
||||||
|
RuleFor(x => x.AddedWho)
|
||||||
|
.NotEmpty()
|
||||||
|
.WithMessage("The 'AddedWho' field is required. A missing value may indicate an API configuration issue. Please contact your system administrator for assistance.");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -7,11 +7,13 @@ using ReC.Domain.Entities;
|
|||||||
|
|
||||||
namespace ReC.Application.Endpoints.Commands;
|
namespace ReC.Application.Endpoints.Commands;
|
||||||
|
|
||||||
|
[Obsolete("Use the related procedure or view.")]
|
||||||
public class ObtainEndpointCommand : IRequest<EndpointDto>
|
public class ObtainEndpointCommand : IRequest<EndpointDto>
|
||||||
{
|
{
|
||||||
public string Uri { get; init; } = null!;
|
public string Uri { get; init; } = null!;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Obsolete("Use the related procedure or view.")]
|
||||||
public class ObtainEndpointCommandHandler(IRepository<Endpoint> repo, IMapper mapper) : IRequestHandler<ObtainEndpointCommand, EndpointDto>
|
public class ObtainEndpointCommandHandler(IRepository<Endpoint> repo, IMapper mapper) : IRequestHandler<ObtainEndpointCommand, EndpointDto>
|
||||||
{
|
{
|
||||||
public async Task<EndpointDto> Handle(ObtainEndpointCommand request, CancellationToken cancel)
|
public async Task<EndpointDto> Handle(ObtainEndpointCommand request, CancellationToken cancel)
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ namespace ReC.Application.Endpoints;
|
|||||||
// TODO: update to inject AddedWho from the current host/user contex
|
// TODO: update to inject AddedWho from the current host/user contex
|
||||||
public class MappingProfile : AutoMapper.Profile
|
public class MappingProfile : AutoMapper.Profile
|
||||||
{
|
{
|
||||||
|
[Obsolete("Use the related procedure or view.")]
|
||||||
public MappingProfile()
|
public MappingProfile()
|
||||||
{
|
{
|
||||||
CreateMap<ObtainEndpointCommand, EndpointDto>()
|
CreateMap<ObtainEndpointCommand, EndpointDto>()
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ using ReC.Domain.Entities;
|
|||||||
|
|
||||||
namespace ReC.Application.OutResults.Commands;
|
namespace ReC.Application.OutResults.Commands;
|
||||||
|
|
||||||
|
[Obsolete("Use the related procedure or view.")]
|
||||||
public class CreateOutResCommand : IRequest
|
public class CreateOutResCommand : IRequest
|
||||||
{
|
{
|
||||||
public required long ActionId { get; set; }
|
public required long ActionId { get; set; }
|
||||||
@@ -19,6 +20,7 @@ public class CreateOutResCommand : IRequest
|
|||||||
public string? AddedWho { get; set; }
|
public string? AddedWho { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Obsolete("Use the related procedure or view.")]
|
||||||
public class CreateOutResCommandHandler(IRepository<OutRes> repo) : IRequestHandler<CreateOutResCommand>
|
public class CreateOutResCommandHandler(IRepository<OutRes> repo) : IRequestHandler<CreateOutResCommand>
|
||||||
{
|
{
|
||||||
public Task Handle(CreateOutResCommand request, CancellationToken cancel)
|
public Task Handle(CreateOutResCommand request, CancellationToken cancel)
|
||||||
|
|||||||
@@ -0,0 +1,26 @@
|
|||||||
|
using DigitalData.Core.Abstraction.Application.Repository;
|
||||||
|
using MediatR;
|
||||||
|
using ReC.Application.Common.Interfaces;
|
||||||
|
using ReC.Domain.Views;
|
||||||
|
using System.Text.Json.Serialization;
|
||||||
|
|
||||||
|
namespace ReC.Application.OutResults.Commands;
|
||||||
|
|
||||||
|
public class CreateResultViewCommand : IAuthScoped, IRequest
|
||||||
|
{
|
||||||
|
public required long ActionId { get; set; }
|
||||||
|
|
||||||
|
public required short StatusCode { get; set; }
|
||||||
|
|
||||||
|
public string? Header { get; set; }
|
||||||
|
|
||||||
|
public string? Body { get; set; }
|
||||||
|
|
||||||
|
[JsonIgnore]
|
||||||
|
public AuthScope Scope { get; } = new();
|
||||||
|
}
|
||||||
|
|
||||||
|
public class CreateResultViewCommandHandler(IRepository<ResultView> repo) : IRequestHandler<CreateResultViewCommand>
|
||||||
|
{
|
||||||
|
public Task Handle(CreateResultViewCommand request, CancellationToken cancel) => repo.CreateAsync(request, cancel);
|
||||||
|
}
|
||||||
@@ -11,6 +11,7 @@ namespace ReC.Application.OutResults.Commands;
|
|||||||
/// Deletion can be performed by providing either an <see cref="ActionId"/> or a <see cref="ProfileId"/>.
|
/// Deletion can be performed by providing either an <see cref="ActionId"/> or a <see cref="ProfileId"/>.
|
||||||
/// At least one of these properties must be set for the operation to proceed.
|
/// At least one of these properties must be set for the operation to proceed.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
|
[Obsolete("Use the related procedure or view.")]
|
||||||
public record DeleteOutResCommand : IRequest
|
public record DeleteOutResCommand : IRequest
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -27,6 +28,7 @@ public record DeleteOutResCommand : IRequest
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Handles the execution of the <see cref="DeleteOutResCommand"/>.
|
/// Handles the execution of the <see cref="DeleteOutResCommand"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
[Obsolete("Use the related procedure or view.")]
|
||||||
public class DeleteOutResCommandHandler(IRepository<OutRes> repo) : IRequestHandler<DeleteOutResCommand>
|
public class DeleteOutResCommandHandler(IRepository<OutRes> repo) : IRequestHandler<DeleteOutResCommand>
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ using FluentValidation;
|
|||||||
|
|
||||||
namespace ReC.Application.OutResults.Commands;
|
namespace ReC.Application.OutResults.Commands;
|
||||||
|
|
||||||
|
[Obsolete("Use the related procedure or view.")]
|
||||||
public class DeleteOutResCommandValidator : AbstractValidator<DeleteOutResCommand>
|
public class DeleteOutResCommandValidator : AbstractValidator<DeleteOutResCommand>
|
||||||
{
|
{
|
||||||
public DeleteOutResCommandValidator()
|
public DeleteOutResCommandValidator()
|
||||||
|
|||||||
@@ -1,15 +1,20 @@
|
|||||||
using ReC.Application.OutResults.Commands;
|
using ReC.Application.OutResults.Commands;
|
||||||
using ReC.Domain.Entities;
|
using ReC.Domain.Entities;
|
||||||
|
using ReC.Domain.Views;
|
||||||
|
|
||||||
namespace ReC.Application.OutResults;
|
namespace ReC.Application.OutResults;
|
||||||
|
|
||||||
// TODO: update to inject AddedWho from the current host/user contex
|
// TODO: update to inject AddedWho from the current host/user contex
|
||||||
public class MappingProfiles : AutoMapper.Profile
|
public class MappingProfiles : AutoMapper.Profile
|
||||||
{
|
{
|
||||||
|
[Obsolete("Use the related procedure or view.")]
|
||||||
public MappingProfiles()
|
public MappingProfiles()
|
||||||
{
|
{
|
||||||
CreateMap<CreateOutResCommand, OutRes>()
|
CreateMap<CreateOutResCommand, OutRes>()
|
||||||
.ForMember(e => e.AddedWhen, exp => exp.MapFrom(cmd => DateTime.UtcNow))
|
.ForMember(e => e.AddedWhen, exp => exp.MapFrom(cmd => DateTime.UtcNow))
|
||||||
.ForMember(e => e.AddedWho, exp => exp.MapFrom(cmd => "ReC.API"));
|
.ForMember(e => e.AddedWho, exp => exp.MapFrom(cmd => "ReC.API"));
|
||||||
|
|
||||||
|
CreateMap<CreateResultViewCommand, ResultView>()
|
||||||
|
.ForMember(e => e.AddedWhen, exp => exp.MapFrom(cmd => DateTime.UtcNow));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -8,6 +8,7 @@ using ReC.Domain.Entities;
|
|||||||
|
|
||||||
namespace ReC.Application.OutResults.Queries;
|
namespace ReC.Application.OutResults.Queries;
|
||||||
|
|
||||||
|
[Obsolete("Use the related procedure or view.")]
|
||||||
public record ReadOutResQuery : IRequest<IEnumerable<OutResDto>>
|
public record ReadOutResQuery : IRequest<IEnumerable<OutResDto>>
|
||||||
{
|
{
|
||||||
public long? ProfileId { get; init; }
|
public long? ProfileId { get; init; }
|
||||||
@@ -15,6 +16,7 @@ public record ReadOutResQuery : IRequest<IEnumerable<OutResDto>>
|
|||||||
public long? ActionId { 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 class ReadOutResHandler(IRepository<OutRes> repo, IMapper mapper) : IRequestHandler<ReadOutResQuery, IEnumerable<OutResDto>>
|
||||||
{
|
{
|
||||||
public async Task<IEnumerable<OutResDto>> Handle(ReadOutResQuery request, CancellationToken cancel)
|
public async Task<IEnumerable<OutResDto>> Handle(ReadOutResQuery request, CancellationToken cancel)
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ using FluentValidation;
|
|||||||
|
|
||||||
namespace ReC.Application.OutResults.Queries;
|
namespace ReC.Application.OutResults.Queries;
|
||||||
|
|
||||||
|
[Obsolete("Use the related procedure or view.")]
|
||||||
public class ReadOutResQueryValidator : AbstractValidator<ReadOutResQuery>
|
public class ReadOutResQueryValidator : AbstractValidator<ReadOutResQuery>
|
||||||
{
|
{
|
||||||
public ReadOutResQueryValidator()
|
public ReadOutResQueryValidator()
|
||||||
|
|||||||
@@ -4,10 +4,10 @@ using DigitalData.Core.Exceptions;
|
|||||||
using MediatR;
|
using MediatR;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using ReC.Application.Common.Dto;
|
using ReC.Application.Common.Dto;
|
||||||
using ReC.Domain.Entities;
|
using ReC.Domain.Views;
|
||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
|
|
||||||
namespace ReC.Application.ResultViews.Queries;
|
namespace ReC.Application.OutResults.Queries;
|
||||||
|
|
||||||
public record ReadResultViewQuery : IRequest<IEnumerable<ResultViewDto>>
|
public record ReadResultViewQuery : IRequest<IEnumerable<ResultViewDto>>
|
||||||
{
|
{
|
||||||
@@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="AutoMapper" Version="15.1.0" />
|
<PackageReference Include="AutoMapper" Version="15.1.0" />
|
||||||
<PackageReference Include="DigitalData.Core.Abstraction.Application" Version="1.5.0" />
|
<PackageReference Include="DigitalData.Core.Abstraction.Application" Version="1.6.0" />
|
||||||
<PackageReference Include="DigitalData.Core.Application" Version="3.4.0" />
|
<PackageReference Include="DigitalData.Core.Application" Version="3.4.0" />
|
||||||
<PackageReference Include="DigitalData.Core.Exceptions" Version="1.1.0" />
|
<PackageReference Include="DigitalData.Core.Exceptions" Version="1.1.0" />
|
||||||
<PackageReference Include="FluentValidation" Version="12.1.0" />
|
<PackageReference Include="FluentValidation" Version="12.1.0" />
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ using ReC.Application.Endpoints.Commands;
|
|||||||
|
|
||||||
namespace ReC.Application.RecActions.Commands;
|
namespace ReC.Application.RecActions.Commands;
|
||||||
|
|
||||||
|
[Obsolete("Use the related procedure or view.")]
|
||||||
public record CreateRecActionCommand : IRequest
|
public record CreateRecActionCommand : IRequest
|
||||||
{
|
{
|
||||||
public long ProfileId { get; init; }
|
public long ProfileId { get; init; }
|
||||||
@@ -27,6 +28,7 @@ public record CreateRecActionCommand : IRequest
|
|||||||
public long? EndpointAuthId { get; set; }
|
public long? EndpointAuthId { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Obsolete("Use the related procedure or view.")]
|
||||||
public class CreateRecActionCommandHandler(ISender sender, IRepository<RecAction> repo) : IRequestHandler<CreateRecActionCommand>
|
public class CreateRecActionCommandHandler(ISender sender, IRepository<RecAction> repo) : IRequestHandler<CreateRecActionCommand>
|
||||||
{
|
{
|
||||||
public async Task Handle(CreateRecActionCommand request, CancellationToken cancel)
|
public async Task Handle(CreateRecActionCommand request, CancellationToken cancel)
|
||||||
|
|||||||
@@ -6,11 +6,13 @@ using ReC.Domain.Entities;
|
|||||||
|
|
||||||
namespace ReC.Application.RecActions.Commands;
|
namespace ReC.Application.RecActions.Commands;
|
||||||
|
|
||||||
|
[Obsolete("Use the related procedure or view.")]
|
||||||
public class DeleteRecActionsCommand : IRequest
|
public class DeleteRecActionsCommand : IRequest
|
||||||
{
|
{
|
||||||
public required long ProfileId { get; init; }
|
public required long ProfileId { get; init; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Obsolete("Use the related procedure or view.")]
|
||||||
public class DeleteRecActionsCommandHandler(IRepository<RecAction> repo) : IRequestHandler<DeleteRecActionsCommand>
|
public class DeleteRecActionsCommandHandler(IRepository<RecAction> repo) : IRequestHandler<DeleteRecActionsCommand>
|
||||||
{
|
{
|
||||||
public async Task Handle(DeleteRecActionsCommand request, CancellationToken cancel)
|
public async Task Handle(DeleteRecActionsCommand request, CancellationToken cancel)
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
using MediatR;
|
using MediatR;
|
||||||
using ReC.Application.RecActionViews.Queries;
|
using ReC.Application.RecActions.Queries;
|
||||||
using ReC.Domain.Constants;
|
using ReC.Domain.Constants;
|
||||||
|
|
||||||
namespace ReC.Application.RecActionViews.Commands;
|
namespace ReC.Application.RecActions.Commands;
|
||||||
|
|
||||||
public record InvokeBatchRecActionViewsCommand : IRequest
|
public record InvokeBatchRecActionViewsCommand : IRequest
|
||||||
{
|
{
|
||||||
@@ -11,7 +11,7 @@ using System.Net.Http.Headers;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
|
|
||||||
namespace ReC.Application.RecActionViews.Commands;
|
namespace ReC.Application.RecActions.Commands;
|
||||||
|
|
||||||
public record InvokeRecActionViewCommand : IRequest<bool>
|
public record InvokeRecActionViewCommand : IRequest<bool>
|
||||||
{
|
{
|
||||||
@@ -1,11 +1,12 @@
|
|||||||
using ReC.Application.Common.Dto;
|
using ReC.Application.Common.Dto;
|
||||||
using ReC.Application.RecActions.Commands;
|
using ReC.Application.RecActions.Commands;
|
||||||
|
|
||||||
namespace ReC.Application.RecActionViews;
|
namespace ReC.Application.RecActions;
|
||||||
|
|
||||||
// TODO: update to inject AddedWho from the current host/user contex
|
// TODO: update to inject AddedWho from the current host/user contex
|
||||||
public class MappingProfile : AutoMapper.Profile
|
public class MappingProfile : AutoMapper.Profile
|
||||||
{
|
{
|
||||||
|
[Obsolete("Use the related procedure or view.")]
|
||||||
public MappingProfile()
|
public MappingProfile()
|
||||||
{
|
{
|
||||||
CreateMap<CreateRecActionCommand, RecActionDto>()
|
CreateMap<CreateRecActionCommand, RecActionDto>()
|
||||||
@@ -1,12 +1,12 @@
|
|||||||
using MediatR;
|
using MediatR;
|
||||||
using DigitalData.Core.Abstraction.Application.Repository;
|
using DigitalData.Core.Abstraction.Application.Repository;
|
||||||
using ReC.Domain.Entities;
|
|
||||||
using AutoMapper;
|
using AutoMapper;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using DigitalData.Core.Exceptions;
|
using DigitalData.Core.Exceptions;
|
||||||
using ReC.Application.Common.Dto;
|
using ReC.Application.Common.Dto;
|
||||||
|
using ReC.Domain.Views;
|
||||||
|
|
||||||
namespace ReC.Application.RecActionViews.Queries;
|
namespace ReC.Application.RecActions.Queries;
|
||||||
|
|
||||||
public record ReadRecActionViewQuery : IRequest<IEnumerable<RecActionViewDto>>
|
public record ReadRecActionViewQuery : IRequest<IEnumerable<RecActionViewDto>>
|
||||||
{
|
{
|
||||||
@@ -1,7 +1,9 @@
|
|||||||
using ReC.Domain.Constants;
|
using ReC.Domain.Constants;
|
||||||
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
|
||||||
namespace ReC.Domain.Entities;
|
namespace ReC.Domain.Views;
|
||||||
|
|
||||||
|
[Table("VWREC_PROFILE", Schema = "dbo")]
|
||||||
public record ProfileView
|
public record ProfileView
|
||||||
{
|
{
|
||||||
public long Id { get; init; }
|
public long Id { get; init; }
|
||||||
@@ -1,7 +1,8 @@
|
|||||||
using ReC.Domain.Constants;
|
using ReC.Domain.Constants;
|
||||||
|
using ReC.Domain.Entities;
|
||||||
using System.ComponentModel.DataAnnotations.Schema;
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
|
||||||
namespace ReC.Domain.Entities;
|
namespace ReC.Domain.Views;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents the VWREC_ACTION view from the database.
|
/// Represents the VWREC_ACTION view from the database.
|
||||||
@@ -1,14 +1,12 @@
|
|||||||
using System.ComponentModel.DataAnnotations.Schema;
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
|
||||||
namespace ReC.Domain.Entities;
|
namespace ReC.Domain.Views;
|
||||||
|
|
||||||
|
[Table("VWREC_RESULT", Schema = "dbo")]
|
||||||
public class ResultView
|
public class ResultView
|
||||||
{
|
{
|
||||||
public long Id { get; set; }
|
public long Id { get; set; }
|
||||||
|
|
||||||
[ForeignKey("Id")]
|
|
||||||
public OutRes? Root { get; set; }
|
|
||||||
|
|
||||||
public long? ActionId { get; set; }
|
public long? ActionId { get; set; }
|
||||||
|
|
||||||
public RecActionView? Action { get; set; }
|
public RecActionView? Action { get; set; }
|
||||||
@@ -1,8 +1,10 @@
|
|||||||
using DigitalData.Core.Infrastructure;
|
using DigitalData.Core.Infrastructure;
|
||||||
|
using FluentValidation;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using ReC.Application.Common.Interfaces;
|
using ReC.Application.Common.Interfaces;
|
||||||
using ReC.Domain.Entities;
|
using ReC.Application.Common.Validations;
|
||||||
|
using ReC.Domain.Views;
|
||||||
|
|
||||||
namespace ReC.Infrastructure;
|
namespace ReC.Infrastructure;
|
||||||
|
|
||||||
@@ -23,6 +25,8 @@ public static class DependencyInjection
|
|||||||
|
|
||||||
services.AddDbRepository(opt => opt.RegisterFromAssembly<TRecDbContext>(typeof(RecActionView).Assembly));
|
services.AddDbRepository(opt => opt.RegisterFromAssembly<TRecDbContext>(typeof(RecActionView).Assembly));
|
||||||
|
|
||||||
|
services.AddValidatorsFromAssembly(typeof(AuthScopedValidator).Assembly);
|
||||||
|
|
||||||
return services;
|
return services;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="DigitalData.Core.Infrastructure" Version="2.5.2" />
|
<PackageReference Include="DigitalData.Core.Infrastructure" Version="2.6.1" />
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="9.0.11" />
|
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="9.0.11" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="10.0.0" />
|
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="10.0.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using ReC.Application.Common.Interfaces;
|
using ReC.Application.Common.Interfaces;
|
||||||
using ReC.Domain.Entities;
|
using ReC.Domain.Entities;
|
||||||
|
using ReC.Domain.Views;
|
||||||
|
|
||||||
namespace ReC.Infrastructure;
|
namespace ReC.Infrastructure;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user