Add Deliveries
This commit is contained in:
76
Elwig/Models/Delivery.cs
Normal file
76
Elwig/Models/Delivery.cs
Normal file
@ -0,0 +1,76 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace Elwig.Models {
|
||||
[Table("delivery"), PrimaryKey("Year", "DId"), Index("DateString", "ZwstId", "LNr", IsUnique = true), Index("LsNr", IsUnique = true)]
|
||||
public class Delivery {
|
||||
[Column("year")]
|
||||
public int Year { get; set; }
|
||||
|
||||
[Column("did")]
|
||||
public int DId { get; set; }
|
||||
|
||||
[Column("date")]
|
||||
public string DateString { get; set; }
|
||||
|
||||
[NotMapped]
|
||||
public DateOnly Date {
|
||||
get {
|
||||
return DateOnly.ParseExact(DateString, "yyyy-MM-dd");
|
||||
}
|
||||
set {
|
||||
DateString = value.ToString("yyyy-MM-dd");
|
||||
}
|
||||
}
|
||||
|
||||
[Column("time")]
|
||||
public string TimeString { get; set; }
|
||||
|
||||
[NotMapped]
|
||||
public TimeOnly Time {
|
||||
get {
|
||||
return TimeOnly.ParseExact(TimeString, "HH:mm:ss");
|
||||
}
|
||||
set {
|
||||
TimeString = value.ToString("HH:mm:ss");
|
||||
}
|
||||
}
|
||||
|
||||
[NotMapped]
|
||||
public DateTime DateTime {
|
||||
get {
|
||||
return Date.ToDateTime(Time);
|
||||
}
|
||||
set {
|
||||
Date = DateOnly.FromDateTime(value);
|
||||
Time = TimeOnly.FromDateTime(value);
|
||||
}
|
||||
}
|
||||
|
||||
[Column("zwstid")]
|
||||
public string ZwstId { get; set; }
|
||||
|
||||
[ForeignKey("ZwstId")]
|
||||
public virtual Branch Branch { get; private set; }
|
||||
|
||||
[Column("lnr")]
|
||||
public int LNr { get; set; }
|
||||
|
||||
[Column("lsnr")]
|
||||
public string LsNr { get; set; }
|
||||
|
||||
[Column("mgnr")]
|
||||
public int MgNr { get; set; }
|
||||
|
||||
[ForeignKey("MgNr")]
|
||||
public virtual Member Member { get; private set; }
|
||||
|
||||
[Column("comment")]
|
||||
public string? Comment { get; set; }
|
||||
|
||||
[InverseProperty("Delivery")]
|
||||
public virtual ISet<DeliveryPart> Parts { get; private set; }
|
||||
}
|
||||
}
|
96
Elwig/Models/DeliveryPart.cs
Normal file
96
Elwig/Models/DeliveryPart.cs
Normal file
@ -0,0 +1,96 @@
|
||||
using Elwig.Helpers;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace Elwig.Models {
|
||||
[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("weight")]
|
||||
public int Weight { get; set; }
|
||||
|
||||
[Column("kmw")]
|
||||
public double Kmw { get; set; }
|
||||
|
||||
[NotMapped]
|
||||
public double Oe {
|
||||
get {
|
||||
return Utils.KmwToOe(Kmw);
|
||||
}
|
||||
set {
|
||||
Kmw = Utils.OeToKmw(value);
|
||||
}
|
||||
}
|
||||
|
||||
[Column("qualid")]
|
||||
public string QualId { get; set; }
|
||||
|
||||
[ForeignKey("QualId")]
|
||||
public virtual WineQual 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("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("comment")]
|
||||
public string? Comment { get; set; }
|
||||
}
|
||||
}
|
@ -35,6 +35,15 @@ namespace Elwig.Models {
|
||||
[Column("suffix")]
|
||||
public string? Suffix { get; set; }
|
||||
|
||||
public string Name =>
|
||||
(Prefix != null ? Prefix + " " : "") +
|
||||
GivenName + " " +
|
||||
(MiddleName != null ? MiddleName + " " : "") +
|
||||
FamilyName +
|
||||
(Suffix != null ? " " + Suffix : "");
|
||||
|
||||
public string ShortName => GivenName + " " + FamilyName;
|
||||
|
||||
[Column("birthday")]
|
||||
public string? Birthday { get; set; }
|
||||
|
||||
@ -153,6 +162,9 @@ namespace Elwig.Models {
|
||||
[InverseProperty("Member")]
|
||||
public virtual BillingAddr? BillingAddress { get; private set; }
|
||||
|
||||
[InverseProperty("Member")]
|
||||
public virtual ISet<Delivery> Deliveries { get; private set; }
|
||||
|
||||
public int SearchScore(IEnumerable<string> keywords) {
|
||||
keywords = keywords.Where(s => s.Length >= 2 || (s.Length > 0 && s.All(c => char.IsAsciiDigit(c))));
|
||||
if (!keywords.Any())
|
||||
|
22
Elwig/Models/WineOrigin.cs
Normal file
22
Elwig/Models/WineOrigin.cs
Normal file
@ -0,0 +1,22 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace Elwig.Models {
|
||||
[Table("wine_origin"), PrimaryKey("HkId"), Index("Name", IsUnique = true)]
|
||||
public class WineOrigin {
|
||||
[Column("hkid")]
|
||||
public string HkId { get; private set; }
|
||||
|
||||
[Column("parent_hkid")]
|
||||
public string? ParentHkId { get; private set; }
|
||||
|
||||
[ForeignKey("ParentHkId")]
|
||||
public virtual WineOrigin? Parent { get; private set; }
|
||||
|
||||
[Column("name")]
|
||||
public string Name { get; private set; }
|
||||
|
||||
[Column("blnr")]
|
||||
public int? BlNr { get; private set; }
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user