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:
@@ -1,11 +0,0 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace GerbilManagerWebAPI.Models
|
||||
{
|
||||
public record Breeder
|
||||
{
|
||||
[Key]
|
||||
public Guid Id { get; init; }
|
||||
public required string Name { get; set; }
|
||||
}
|
||||
}
|
||||
18
GerbilManagerWebAPI/Models/ColorVariety.cs
Normal file
18
GerbilManagerWebAPI/Models/ColorVariety.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace GerbilManagerWebAPI.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// A Farbschlag (colour variety). Seeded from the GEN-1 catalog (source of truth)
|
||||
/// and user-extendable. Gerbils reference it via Gerbil.ColorVarietyId.
|
||||
/// </summary>
|
||||
public class ColorVariety
|
||||
{
|
||||
[Key]
|
||||
public Guid Id { get; set; }
|
||||
public required string Name { get; set; }
|
||||
/// <summary>Reference (representative) compact genotype string for this variety.</summary>
|
||||
public string? CanonicalGenotype { get; set; }
|
||||
public int SortOrder { get; set; }
|
||||
}
|
||||
}
|
||||
17
GerbilManagerWebAPI/Models/Contact.cs
Normal file
17
GerbilManagerWebAPI/Models/Contact.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace GerbilManagerWebAPI.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// A person/cattery a gerbil came from (Herkunft) or was given to (Abnehmer).
|
||||
/// Was "Breeder"; the role is relational (see Gerbil.OriginContactId / ReceiverContactId).
|
||||
/// </summary>
|
||||
public class Contact
|
||||
{
|
||||
[Key]
|
||||
public Guid Id { get; set; }
|
||||
public required string Name { get; set; }
|
||||
public string? ContactInfo { get; set; }
|
||||
public string? Notes { get; set; }
|
||||
}
|
||||
}
|
||||
15
GerbilManagerWebAPI/Models/Enclosure.cs
Normal file
15
GerbilManagerWebAPI/Models/Enclosure.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace GerbilManagerWebAPI.Models
|
||||
{
|
||||
/// <summary>A tank/cage (Becken) that gerbils currently live in.</summary>
|
||||
public class Enclosure
|
||||
{
|
||||
[Key]
|
||||
public Guid Id { get; set; }
|
||||
public required string Name { get; set; }
|
||||
public string? Notes { get; set; }
|
||||
|
||||
public ICollection<Gerbil> Gerbils { get; } = new List<Gerbil>();
|
||||
}
|
||||
}
|
||||
@@ -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; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
17
GerbilManagerWebAPI/Models/GerbilPhoto.cs
Normal file
17
GerbilManagerWebAPI/Models/GerbilPhoto.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace GerbilManagerWebAPI.Models
|
||||
{
|
||||
/// <summary>A photo of a gerbil. The file lives under a configured FS root; only the
|
||||
/// file name is stored in the DB. The first photo by SortOrder is the profile photo.</summary>
|
||||
public class GerbilPhoto
|
||||
{
|
||||
[Key]
|
||||
public Guid Id { get; set; }
|
||||
public Guid GerbilId { get; set; }
|
||||
public required string FileName { get; set; }
|
||||
public string? Caption { get; set; }
|
||||
public int SortOrder { get; set; }
|
||||
public DateTimeOffset CreatedAt { get; set; }
|
||||
}
|
||||
}
|
||||
10
GerbilManagerWebAPI/Models/GerbilStatus.cs
Normal file
10
GerbilManagerWebAPI/Models/GerbilStatus.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
namespace GerbilManagerWebAPI.Models
|
||||
{
|
||||
/// <summary>Lifecycle status of a gerbil. Serialised as the string name on the wire.</summary>
|
||||
public enum GerbilStatus
|
||||
{
|
||||
Active = 0,
|
||||
Deceased = 1,
|
||||
GivenAway = 2
|
||||
}
|
||||
}
|
||||
17
GerbilManagerWebAPI/Models/HealthRecord.cs
Normal file
17
GerbilManagerWebAPI/Models/HealthRecord.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace GerbilManagerWebAPI.Models
|
||||
{
|
||||
/// <summary>A medical-log entry for a gerbil (Gesundheitseintrag).</summary>
|
||||
public class HealthRecord
|
||||
{
|
||||
[Key]
|
||||
public Guid Id { get; set; }
|
||||
public Guid GerbilId { get; set; }
|
||||
public DateOnly Date { get; set; }
|
||||
public HealthRecordType Type { get; set; }
|
||||
public required string Description { get; set; }
|
||||
public string? Veterinarian { get; set; }
|
||||
public DateTimeOffset CreatedAt { get; set; }
|
||||
}
|
||||
}
|
||||
12
GerbilManagerWebAPI/Models/HealthRecordType.cs
Normal file
12
GerbilManagerWebAPI/Models/HealthRecordType.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
namespace GerbilManagerWebAPI.Models
|
||||
{
|
||||
/// <summary>Kind of health-record entry. Serialised as the string name on the wire.</summary>
|
||||
public enum HealthRecordType
|
||||
{
|
||||
Examination = 0,
|
||||
Treatment = 1,
|
||||
Injury = 2,
|
||||
Vaccination = 3,
|
||||
Other = 4
|
||||
}
|
||||
}
|
||||
@@ -2,15 +2,24 @@ using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace GerbilManagerWebAPI.Models
|
||||
{
|
||||
public record Litter
|
||||
/// <summary>A litter (Wurf). Parents are gerbils; juveniles are Gerbils linked via Gerbil.LitterId.</summary>
|
||||
public class Litter
|
||||
{
|
||||
[Key]
|
||||
public Guid Id { get; init; }
|
||||
public Guid Id { get; set; }
|
||||
public required string Name { get; set; }
|
||||
public required DateTime Date { get; set; }
|
||||
public int? Strength { get; set; }
|
||||
public DateOnly Date { get; set; }
|
||||
|
||||
/// <summary>Total born count (was "Strength").</summary>
|
||||
public int? TotalBorn { get; set; }
|
||||
|
||||
public Guid? FatherId { get; set; }
|
||||
public Gerbil? Father { get; set; }
|
||||
public Guid? MotherId { get; set; }
|
||||
public Gerbil? Mother { get; set; }
|
||||
|
||||
/// <summary>Computed ~35 days after Date by default; editable.</summary>
|
||||
public DateOnly? ExpectedGoHomeDate { get; set; }
|
||||
public string? Notes { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
15
GerbilManagerWebAPI/Models/WeightRecord.cs
Normal file
15
GerbilManagerWebAPI/Models/WeightRecord.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace GerbilManagerWebAPI.Models
|
||||
{
|
||||
/// <summary>A weight measurement for a gerbil (Gewichtseintrag), in grams.</summary>
|
||||
public class WeightRecord
|
||||
{
|
||||
[Key]
|
||||
public Guid Id { get; set; }
|
||||
public Guid GerbilId { get; set; }
|
||||
public DateOnly Date { get; set; }
|
||||
public int WeightGrams { get; set; }
|
||||
public string? Notes { get; set; }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user