PlanTempusApp/PlanTempus.Components/Accounts/Create/CreateAccountController.cs
Janus C. H. Knudsen 88812177a9 Migrate from User to Account domain concept
Renames core domain entities and services from "User" to "Account"

Refactors project-wide namespaces, classes, and database tables to use "Account" terminology
Updates related components, services, and database schema to reflect new domain naming
Standardizes naming conventions across authentication and organization setup features
2026-01-09 22:14:46 +01:00

31 lines
967 B
C#

using Microsoft.AspNetCore.Mvc;
using PlanTempus.Core.CommandQueries;
namespace PlanTempus.Components.Accounts.Create
{
[ApiController]
[Route("api/accounts")]
public class CreateAccountController(CreateAccountHandler handler, CreateAccountValidator validator) : ControllerBase
{
[HttpPost]
public async Task<ActionResult<CommandResponse>> Create([FromBody] CreateAccountCommand command)
{
try
{
var validationResult = await validator.ValidateAsync(command);
if (!validationResult.IsValid)
{
return BadRequest(validationResult.Errors);
}
var result = await handler.Handle(command);
return Accepted($"/api/requests/{result.RequestId}", result);
}
catch (Exception ex)
{
return BadRequest(ex.Message);
}
}
}
}