Models: Add Entities/ folder

This commit is contained in:
2023-11-10 13:48:25 +01:00
parent 2f98df87a0
commit 32f229b0a5
63 changed files with 63 additions and 68 deletions

View File

@ -0,0 +1,120 @@
using Elwig.Helpers;
using Microsoft.EntityFrameworkCore;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
namespace Elwig.Models.Entities {
[Table("delivery_part"), PrimaryKey("Year", "DId", "DPNr")]
public class DeliveryPart {
[Column("year")]
public int Year { get; set; }
[Column("did")]
public int DId { get; set; }
[ForeignKey("Year, DId")]
public virtual Delivery Delivery { get; private set; }
[Column("dpnr")]
public int DPNr { get; set; }
[Column("sortid")]
public string SortId { get; set; }
[ForeignKey("SortId")]
public virtual WineVar Variant { get; private set; }
[Column("attrid")]
public string? AttrId { get; set; }
[ForeignKey("AttrId")]
public virtual WineAttr? Attribute { get; private set; }
[Column("weight")]
public int Weight { get; set; }
[Column("kmw")]
public double Kmw { get; set; }
[NotMapped]
public double Oe {
get => Utils.KmwToOe(Kmw);
set => Kmw = Utils.OeToKmw(value);
}
[Column("qualid")]
public string QualId { get; set; }
[ForeignKey("QualId")]
public virtual WineQualLevel Quality { get; private set; }
[Column("hkid")]
public string HkId { get; set; }
[ForeignKey("HkId")]
public virtual WineOrigin Origin { get; private set; }
[Column("kgnr")]
public int? KgNr { get; set; }
[ForeignKey("KgNr")]
public virtual WbKg? Kg { get; private set; }
[Column("rdnr")]
public int? RdNr { get; set; }
[ForeignKey("KgNr, RdNr")]
public virtual WbRd? Rd { get; private set; }
[Column("gerebelt")]
public bool IsGerebelt { get; set; }
[Column("manual_weighing")]
public bool ManualWeighing { get; set; }
[Column("spl_check")]
public bool SplCheck { get; set; }
[Column("hand_picked")]
public bool? IsHandPicked { get; set; }
[Column("lesewagen")]
public bool? IsLesewagen { get; set; }
[Column("gebunden")]
public bool? IsGebunden { get; set; }
[Column("temperature")]
public double? Temperature { get; set; }
[Column("acid")]
public double? Acid { get; set; }
[Column("scale_id")]
public string? ScaleId { get; set; }
[Column("weighing_id")]
public string? WeighingId { get; set; }
[Column("weighing_reason")]
public string? WeighingReason { get; set; }
[Column("comment")]
public string? Comment { get; set; }
[InverseProperty("Part")]
public virtual ISet<DeliveryPartModifier> PartModifiers { get; private set; }
[NotMapped]
public IEnumerable<Modifier> Modifiers => PartModifiers.Select(m => m.Modifier).OrderBy(m => m.Ordering);
[InverseProperty("DeliveryPart")]
public virtual PaymentDeliveryPart? Payment { get; private set; }
[NotMapped]
public string OriginString => Origin.OriginString + "\n" + (Kg?.Gl != null ? $" / {Kg.Gl.Name}" : "") + (Kg != null ? $" / {Kg.AtKg.Gem.Name} / KG {Kg.AtKg.Name}" : "") + (Rd != null ? $" / Ried {Rd.Name}" : "");
[InverseProperty("Part")]
public virtual ISet<DeliveryPartBucket> Buckets { get; private set; }
}
}