conocimientogenerador-crudtemplates/1899 B
Command.cs.template
Fichero que /hv:generador-crud usa o materializa en el proyecto. Se muestra tal cual está en el plugin.
// ============================================================================
// TEMPLATE: Command.cs - Comandos CQRS con Mediator (por entidad)
// Skill: generador-crud (ADR-031)
// ============================================================================
// USO: Reemplazar {{Entity}}, {{Entities}}, {{Namespace}} y el fragmento {{PropiedadesCommand}}
// Destino: src/Application/Features/{{Entities}}/Commands/{{Entity}}Commands.cs
// Mediator (martinothamar, MIT) en lugar de MediatR (comercial desde v13). Los handlers estan en
// CommandHandler.cs; la validacion, en Validator.cs (pipeline de Mediator o filtro de Minimal API).
// ============================================================================
using Mediator;
using {{Namespace}}.Application.Features.{{Entities}}.Dtos;
namespace {{Namespace}}.Application.Features.{{Entities}}.Commands;
/// <summary>Crea un/a {{Entity}}. Devuelve el DTO creado.</summary>
public sealed record Create{{Entity}}Command : ICommand<{{Entity}}Dto>
{
{{PropiedadesCommand}}
}
/// <summary>Actualiza un/a {{Entity}} existente. El Id viene de la ruta.</summary>
public sealed record Update{{Entity}}Command : ICommand
{
public int Id { get; init; }
{{PropiedadesCommand}}
}
/// <summary>Borrado logico de un/a {{Entity}}.</summary>
public sealed record Delete{{Entity}}Command(int Id) : ICommand;
// ============================================================================
// EJEMPLO GENERADO
// ============================================================================
/*
public sealed record CreateScholarshipCommand : ICommand<ScholarshipDto>
{
public required string Code { get; init; }
public required string Name { get; init; }
public string? Description { get; init; }
public decimal Amount { get; init; }
public DateOnly StartDate { get; init; }
public DateOnly EndDate { get; init; }
}
*/