[#77] Entities: Add AreaComContract to group area commitments together

This commit is contained in:
2026-03-30 19:35:53 +02:00
parent f96ebdcf60
commit 4460de9975
26 changed files with 918 additions and 335 deletions

View File

@@ -1,15 +1,16 @@
using Elwig.Helpers;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
namespace Elwig.Models.Entities {
[Table("area_commitment"), PrimaryKey("FbNr")]
[Table("area_commitment"), PrimaryKey("FbNr", "RevNr")]
public class AreaCom {
[Column("fbnr")]
public int FbNr { get; set; }
[Column("revnr")]
public int RevNr { get; set; }
[Column("mgnr")]
public int MgNr { get; set; }
@@ -22,24 +23,15 @@ namespace Elwig.Models.Entities {
[Column("area")]
public int Area { get; set; }
[Column("kgnr")]
public int KgNr { get; set; }
[Column("gstnr")]
public required string GstNr { get; set; }
[Column("rdnr")]
public int? RdNr { get; set; }
[Column("year_from")]
public int? YearFrom { get; set; }
[Column("year_to")]
public int? YearTo { get; set; }
[Column("comment")]
public string? Comment { get; set; }
[Column("ctime"), DatabaseGenerated(DatabaseGeneratedOption.Computed)]
public long CTime { get; set; }
[NotMapped]
@@ -72,6 +64,9 @@ namespace Elwig.Models.Entities {
set => ITime = value == null ? null : ((DateTimeOffset)value.Value.ToUniversalTime()).ToUnixTimeSeconds();
}
[ForeignKey("FbNr")]
public virtual AreaComContract Contract { get; private set; } = null!;
[ForeignKey("MgNr")]
public virtual Member Member { get; private set; } = null!;
@@ -80,17 +75,5 @@ namespace Elwig.Models.Entities {
[ForeignKey("CultId")]
public virtual WineCult? WineCult { get; private set; }
[ForeignKey("KgNr")]
public virtual WbKg Kg { get; private set; } = null!;
[ForeignKey("KgNr, RdNr")]
public virtual WbRd? Rd { get; private set; }
public int SearchScore(IEnumerable<string> keywords) {
return Utils.GetSearchScore([
WineCult?.Name, Kg.AtKg.Name, Rd?.Name, GstNr, Comment,
], keywords);
}
}
}