- Entities: Breeder->Contact, +Enclosure/ColorVariety/GerbilPhoto/HealthRecord/WeightRecord;
Gerbil expanded (single Genotype text col, Status/Gender enums-as-string, FK ids,
ImportSource/ExternalRef provenance); Litter Strength->TotalBorn +ExpectedGoHomeDate/Notes.
ColorVariety HasData seed = 18 from GEN-1 catalog. Gerbil<->Litter cycle handled
(SetNull/Restrict). Enums stored as strings.
- Minimal API (no controllers): Endpoints/*.cs MapGroup+TypedResults for gerbils, litters,
contacts, enclosures, color-varieties, health/weight-records, inbreeding (converted from
controller, same routes/shapes), photos (Oscar contract: GET array/POST multipart/DELETE,
url /photos/files/{fileName}). Gridify paged {items,totalCount,page,pageSize}, camelCase,
409 conflict-deletes, flat FK ids, litter parent-gender validation (400 {code,...}).
- Scalar replaces Swashbuckle (AddOpenApi/MapOpenApi + MapScalarApiReference at /scalar);
launchUrl swagger->scalar. GenericRepository/UnitOfWork/Converters deleted; DbContext direct.
- InbreedingService reads real FK props now; pure calculator + 8 tests untouched.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
34 lines
1.3 KiB
C#
34 lines
1.3 KiB
C#
using GerbilManagerWebAPI.Dtos;
|
|
using GerbilManagerWebAPI.Genetics;
|
|
using Microsoft.AspNetCore.Http.HttpResults;
|
|
|
|
namespace GerbilManagerWebAPI.Endpoints
|
|
{
|
|
/// <summary>
|
|
/// Inzuchtkoeffizient endpoints (FEAT-1b). Routes/response shapes are IDENTICAL to
|
|
/// the former InbreedingController — only the hosting style changed to Minimal API.
|
|
/// </summary>
|
|
public static class InbreedingEndpoints
|
|
{
|
|
public static IEndpointRouteBuilder MapInbreedingEndpoints(this IEndpointRouteBuilder app)
|
|
{
|
|
// GET /gerbils/{id}/inbreeding-coefficient
|
|
app.MapGet("/gerbils/{id:guid}/inbreeding-coefficient",
|
|
Results<Ok<InbreedingResult>, NotFound> (Guid id, ApplicationContext db) =>
|
|
{
|
|
var result = new InbreedingService(db).ForGerbil(id);
|
|
return result is null ? TypedResults.NotFound() : TypedResults.Ok(result);
|
|
})
|
|
.WithTags("Inbreeding");
|
|
|
|
// POST /genetics/test-inbreeding
|
|
app.MapPost("/genetics/test-inbreeding",
|
|
Ok<InbreedingResult> (TestInbreedingDto dto, ApplicationContext db) =>
|
|
TypedResults.Ok(new InbreedingService(db).ForPairing(dto.FatherId, dto.MotherId)))
|
|
.WithTags("Inbreeding");
|
|
|
|
return app;
|
|
}
|
|
}
|
|
}
|