This commit is contained in:
Janus Knudsen 2025-03-05 16:56:58 +01:00
parent 91da89a4e8
commit a15cc00595
4 changed files with 20 additions and 36 deletions

View file

@ -3,25 +3,17 @@ using PlanTempus.Core.Sql;
namespace PlanTempus.Components.Organizations.Create
{
public class CreateOrganizationHandler
public class CreateOrganizationHandler(IDatabaseOperations databaseOperations)
{
private readonly IDatabaseOperations _databaseOperations;
public CreateOrganizationHandler(IDatabaseOperations databaseOperations)
{
_databaseOperations = databaseOperations;
}
public async Task<CreateOrganizationResult> Handle(CreateOrganizationCommand command)
{
using var db = _databaseOperations.CreateScope(nameof(CreateOrganizationHandler));
using var db = databaseOperations.CreateScope(nameof(CreateOrganizationHandler));
try
{
var sql = @"
INSERT INTO organizations (connection_string, created_by)
VALUES (@ConnectionString, @CreatedBy)
RETURNING id, created_at";
var sql = @"INSERT INTO organizations (connection_string, created_by)
VALUES (@ConnectionString, @CreatedBy)
RETURNING id, created_at";
var data = await db.Connection.QuerySqlAsync<CreateOrganizationResult>(sql, new

View file

@ -18,6 +18,7 @@ namespace PlanTempus.Components.Users.Create
}
var result = await handler.Handle(command);
return CreatedAtAction(
nameof(CreateUserCommand),
"GetUser",