DATA-2: new schema entities + Minimal API endpoints + Scalar + DAL teardown
- 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>
This commit is contained in:
@@ -2,13 +2,49 @@ using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace GerbilManagerWebAPI.Models
|
||||
{
|
||||
public record Gerbil
|
||||
/// <summary>
|
||||
/// A gerbil (Rennmaus). Pedigree is traversed via Litter → Father/Mother (no redundant
|
||||
/// parent FKs here). Genotype is one compact frozen-contract string (e.g.
|
||||
/// "Aa CC Dd EE GG Pp Spsp rere", "?" wildcards allowed); never SQL-filtered.
|
||||
/// </summary>
|
||||
public class Gerbil
|
||||
{
|
||||
[Key]
|
||||
public Guid Id { get; init; } // init => properties are immutable by default, they are only mutable in the constructor and initializer.
|
||||
public required string Name { get; set; } //required => parameter is necessary in constructor and object iniilization list. So it cannot be intantiated without it
|
||||
public required Gender Gender { get; set; }
|
||||
public Litter? Litter { get; set; } // Any variable where the ? isn't appended to the type name is a non-nullable reference type.
|
||||
public Breeder? Breeder { get; set; } // You use the null-forgiving operator ! following a variable name to force the null-state to be not-null. For example, if you know the name variable isn't null but the compiler issues a warning, you can write the following code to override the compiler's analysis:
|
||||
public Guid Id { get; set; }
|
||||
public required string Name { get; set; }
|
||||
public Gender Gender { get; set; }
|
||||
public GerbilStatus Status { get; set; } = GerbilStatus.Active;
|
||||
|
||||
// Birth litter (the litter this gerbil was born in).
|
||||
public Guid? LitterId { get; set; }
|
||||
public Litter? Litter { get; set; }
|
||||
|
||||
// Contacts: Herkunft (origin) and Abnehmer (receiver, when given away).
|
||||
public Guid? OriginContactId { get; set; }
|
||||
public Contact? OriginContact { get; set; }
|
||||
public Guid? ReceiverContactId { get; set; }
|
||||
public Contact? ReceiverContact { get; set; }
|
||||
|
||||
// Current home.
|
||||
public Guid? EnclosureId { get; set; }
|
||||
public Enclosure? Enclosure { get; set; }
|
||||
|
||||
// Farbschlag.
|
||||
public Guid? ColorVarietyId { get; set; }
|
||||
public ColorVariety? ColorVariety { get; set; }
|
||||
|
||||
public DateOnly? DateOfBirth { get; set; }
|
||||
public DateOnly? DateOfDeath { get; set; }
|
||||
public string? CauseOfDeath { get; set; }
|
||||
public DateOnly? GoHomeDate { get; set; }
|
||||
|
||||
/// <summary>Compact genotype string (frozen GEN-1 contract). Null = not genotyped.</summary>
|
||||
public string? Genotype { get; set; }
|
||||
|
||||
public string? Notes { get; set; }
|
||||
|
||||
// Provenance (for the FEAT-8 spreadsheet import).
|
||||
public string? ImportSource { get; set; }
|
||||
public string? ExternalRef { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user