Add POST endpoint to create ResultView in controller
Added a new HTTP POST action to ResultViewController that accepts a CreateResultViewCommand in the request body. On success, it returns a 201 Created response with a reference to the Get action for the created resource. This enables clients to create new ResultView entries via the API.
This commit is contained in:
@@ -2,6 +2,7 @@
|
|||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using ReC.API.Extensions;
|
using ReC.API.Extensions;
|
||||||
using ReC.API.Models;
|
using ReC.API.Models;
|
||||||
|
using ReC.Application.ResultViews.Commands;
|
||||||
using ReC.Application.ResultViews.Queries;
|
using ReC.Application.ResultViews.Queries;
|
||||||
|
|
||||||
namespace ReC.API.Controllers;
|
namespace ReC.API.Controllers;
|
||||||
@@ -38,4 +39,11 @@ public class ResultViewController(IMediator mediator, IConfiguration config) : C
|
|||||||
_ => 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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user