Renommage : TrajetKmTracker -> SchotzIadKmTracker (backend, specs, frontend)
- Backend : projets, solution, namespaces et références TrajetKmTracker.Api/.Tests -> SchotzIadKmTracker.Api/.Tests (dossiers, .csproj, .sln, .http, namespaces C#). GUID UserSecretsId préservé. - Specs : dossier .kiro/specs/trajet-km-tracker -> schotziad-km-tracker et mise à jour des références internes (chemins, tags de propriétés). - Frontend : projet Angular trajet-km-tracker -> schotziad-km-tracker (package.json, angular.json, chemin dist, Dockerfile), titre applicatif 'SchotzIAD KM Tracker'. - Docker et scripts (backend/Dockerfile, frontend/Dockerfile, run-dev.sh) mis à jour. - Suppression du fichier résiduel package.json.bak. Backend (solution) et frontend (build production) compilent sans erreur.
This commit is contained in:
@@ -0,0 +1,88 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using SchotzIadKmTracker.Api.Models.DTOs;
|
||||
using SchotzIadKmTracker.Api.Services;
|
||||
using SchotzIadKmTracker.Api.Services.Exceptions;
|
||||
|
||||
namespace SchotzIadKmTracker.Api.Controllers;
|
||||
|
||||
/// <summary>
|
||||
/// Endpoints de gestion des véhicules : historique, véhicule courant, création et réaffectation.
|
||||
/// </summary>
|
||||
[ApiController]
|
||||
[Route("api/vehicules")]
|
||||
public class VehiculesController : ControllerBase
|
||||
{
|
||||
private readonly IVehiculeService _vehiculeService;
|
||||
|
||||
public VehiculesController(IVehiculeService vehiculeService)
|
||||
{
|
||||
_vehiculeService = vehiculeService;
|
||||
}
|
||||
|
||||
/// <summary>Historique complet des véhicules (trié par date d'effet décroissante).</summary>
|
||||
[HttpGet]
|
||||
[ProducesResponseType(typeof(IReadOnlyList<VehiculeDto>), StatusCodes.Status200OK)]
|
||||
public async Task<ActionResult<IReadOnlyList<VehiculeDto>>> GetHistorique(CancellationToken cancellationToken)
|
||||
{
|
||||
var vehicules = await _vehiculeService.GetHistoriqueAsync(cancellationToken);
|
||||
return Ok(vehicules);
|
||||
}
|
||||
|
||||
/// <summary>Véhicule courant (date d'effet la plus récente ≤ aujourd'hui).</summary>
|
||||
[HttpGet("courant")]
|
||||
[ProducesResponseType(typeof(VehiculeDto), StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
||||
public async Task<ActionResult<VehiculeDto>> GetCourant(CancellationToken cancellationToken)
|
||||
{
|
||||
try
|
||||
{
|
||||
var vehicule = await _vehiculeService.GetVehiculeCourantAsync(cancellationToken);
|
||||
return Ok(vehicule);
|
||||
}
|
||||
catch (VehiculeNotFoundException ex)
|
||||
{
|
||||
return Problem(detail: ex.Message, statusCode: StatusCodes.Status404NotFound);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Enregistre un véhicule. Retourne <see cref="VehiculeCreeDto"/> indiquant si une réaffectation
|
||||
/// des trajets doit être proposée. Rejette une date d'effet future (400).
|
||||
/// </summary>
|
||||
[HttpPost]
|
||||
[ProducesResponseType(typeof(VehiculeCreeDto), StatusCodes.Status201Created)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
public async Task<ActionResult<VehiculeCreeDto>> Create(
|
||||
[FromBody] CreateVehiculeDto dto,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
try
|
||||
{
|
||||
var resultat = await _vehiculeService.CreateAsync(dto, cancellationToken);
|
||||
return CreatedAtAction(nameof(GetHistorique), null, resultat);
|
||||
}
|
||||
catch (DateEffetFutureException ex)
|
||||
{
|
||||
return Problem(detail: ex.Message, statusCode: StatusCodes.Status400BadRequest);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Accepte ou refuse la réaffectation des trajets au véhicule indiqué.</summary>
|
||||
[HttpPost("reaffectation")]
|
||||
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
||||
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
||||
public async Task<IActionResult> Reaffecter(
|
||||
[FromBody] ReaffectationDto dto,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
try
|
||||
{
|
||||
await _vehiculeService.ReaffecterAsync(dto, cancellationToken);
|
||||
return NoContent();
|
||||
}
|
||||
catch (VehiculeNotFoundException ex)
|
||||
{
|
||||
return Problem(detail: ex.Message, statusCode: StatusCodes.Status404NotFound);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user