Add Get endpoint and refactor ReadRecActionQuery
Added a new Get endpoint to RecActionController to fetch data based on profileId using ReadRecActionQuery. Updated ReadRecActionQuery to support long ProfileId, added a parameterless constructor, and refactored its structure. Adjusted ReadRecActionQueryHandler to align with these changes.
This commit is contained in:
parent
edfbfd8e6c
commit
a99f2d55b2
@ -2,6 +2,7 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using ReC.API.Models;
|
||||
using ReC.Application.RecActions.Commands;
|
||||
using ReC.Application.RecActions.Queries;
|
||||
using System.IO;
|
||||
using System.Text.Json;
|
||||
|
||||
@ -11,6 +12,12 @@ namespace ReC.API.Controllers;
|
||||
[ApiController]
|
||||
public class RecActionController(IMediator mediator) : ControllerBase
|
||||
{
|
||||
[HttpGet]
|
||||
public async Task<IActionResult> Get([FromQuery] long profileId) => Ok(await mediator.Send(new ReadRecActionQuery()
|
||||
{
|
||||
ProfileId = profileId
|
||||
}));
|
||||
|
||||
[HttpPost("{profileId}")]
|
||||
public async Task<IActionResult> Invoke([FromRoute] int profileId)
|
||||
{
|
||||
|
||||
@ -10,12 +10,17 @@ namespace ReC.Application.RecActions.Queries;
|
||||
|
||||
public record ReadRecActionQueryBase
|
||||
{
|
||||
public int ProfileId { get; init; }
|
||||
public long ProfileId { get; init; }
|
||||
|
||||
public ReadRecActionQuery ToReadQuery() => new(this);
|
||||
}
|
||||
|
||||
public record ReadRecActionQuery(ReadRecActionQueryBase Root) : ReadRecActionQueryBase(Root), IRequest<IEnumerable<RecActionDto>>;
|
||||
public record ReadRecActionQuery : ReadRecActionQueryBase, IRequest<IEnumerable<RecActionDto>>
|
||||
{
|
||||
public ReadRecActionQuery(ReadRecActionQueryBase root) : base(root) { }
|
||||
|
||||
public ReadRecActionQuery() { }
|
||||
}
|
||||
|
||||
public class ReadRecActionQueryHandler(IRepository<RecActionView> repo, IMapper mapper) : IRequestHandler<ReadRecActionQuery, IEnumerable<RecActionDto>>
|
||||
{
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user