books/backend/Books.Api/Commands/Accounts/AccountCommandHandlers.cs
Nicolaj Hartmann 1f75c5d791 Add all backend domain, commands, repositories, and tests
This commit includes all previously untracked backend files:

Domain:
- Accounts, Attachments, BankConnections, Customers
- FiscalYears, Invoices, JournalEntryDrafts
- Orders, Products, UserAccess

Commands & Handlers:
- Full CQRS command structure for all domains

Repositories:
- PostgreSQL repositories for all read models
- Bank transaction and ledger repositories

GraphQL:
- Input types, scalars, and types for all entities
- Mutations and queries

Infrastructure:
- Banking integration (Enable Banking client)
- File storage, Invoicing, Reporting, SAF-T export
- Database migrations (003-029)

Tests:
- Integration tests for GraphQL endpoints
- Domain tests
- Invoicing and reporting tests

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 22:19:42 +01:00

67 lines
1.9 KiB
C#

using Books.Api.Domain.Accounts;
using EventFlow.Commands;
namespace Books.Api.Commands.Accounts;
public class CreateAccountCommandHandler : CommandHandler<AccountAggregate, AccountId, CreateAccountCommand>
{
public override Task ExecuteAsync(
AccountAggregate aggregate,
CreateAccountCommand command,
CancellationToken cancellationToken)
{
aggregate.Create(
command.CompanyId,
command.AccountNumber,
command.Name,
command.AccountType,
command.ParentId,
command.Description,
command.VatCodeId,
command.IsSystemAccount,
command.StandardAccountNumber);
return Task.CompletedTask;
}
}
public class UpdateAccountCommandHandler : CommandHandler<AccountAggregate, AccountId, UpdateAccountCommand>
{
public override Task ExecuteAsync(
AccountAggregate aggregate,
UpdateAccountCommand command,
CancellationToken cancellationToken)
{
aggregate.Update(
command.Name,
command.ParentId,
command.Description,
command.VatCodeId);
return Task.CompletedTask;
}
}
public class DeactivateAccountCommandHandler : CommandHandler<AccountAggregate, AccountId, DeactivateAccountCommand>
{
public override Task ExecuteAsync(
AccountAggregate aggregate,
DeactivateAccountCommand command,
CancellationToken cancellationToken)
{
aggregate.Deactivate();
return Task.CompletedTask;
}
}
public class ReactivateAccountCommandHandler : CommandHandler<AccountAggregate, AccountId, ReactivateAccountCommand>
{
public override Task ExecuteAsync(
AccountAggregate aggregate,
ReactivateAccountCommand command,
CancellationToken cancellationToken)
{
aggregate.Reactivate();
return Task.CompletedTask;
}
}