- PedigreeCalculator: pure, EF-free Wright path-method engine (recursive F_A,
per-common-ancestor contributions, generationsAvailable, cycle guards)
- InbreedingService: loads pedigree from ApplicationContext shadow FKs
(Gerbils.LitterId, Litters.FatherId/MotherId) into in-memory maps
- InbreedingController: GET /gerbils/{id}/inbreeding-coefficient,
POST /genetics/test-inbreeding (hypothetical pairing for Probeverpaarung)
- Injects ApplicationContext directly; no Program.cs change (Dwight owns it)
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
40 lines
1.3 KiB
C#
40 lines
1.3 KiB
C#
using GerbilManagerWebAPI.DAL;
|
|
using GerbilManagerWebAPI.Dtos;
|
|
using GerbilManagerWebAPI.Genetics;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
namespace GerbilManagerWebAPI.Controllers
|
|
{
|
|
/// <summary>
|
|
/// Inbreeding-coefficient (Inzuchtkoeffizient) endpoints — both for an existing
|
|
/// gerbil and for a hypothetical pairing (Probeverpaarung).
|
|
/// </summary>
|
|
[ApiController]
|
|
public class InbreedingController : ControllerBase
|
|
{
|
|
private readonly InbreedingService service;
|
|
|
|
// ApplicationContext is already registered in DI; the service is a thin,
|
|
// dependency-free wrapper so it needs no separate registration in Program.cs.
|
|
public InbreedingController(ApplicationContext db)
|
|
{
|
|
service = new InbreedingService(db);
|
|
}
|
|
|
|
// GET /gerbils/{id}/inbreeding-coefficient
|
|
[HttpGet("gerbils/{id}/inbreeding-coefficient")]
|
|
public ActionResult<InbreedingResult> GetForGerbil(Guid id)
|
|
{
|
|
var result = service.ForGerbil(id);
|
|
return result is null ? NotFound() : result;
|
|
}
|
|
|
|
// POST /genetics/test-inbreeding
|
|
[HttpPost("genetics/test-inbreeding")]
|
|
public ActionResult<InbreedingResult> TestPairing(TestInbreedingDto dto)
|
|
{
|
|
return service.ForPairing(dto.FatherId, dto.MotherId);
|
|
}
|
|
}
|
|
}
|