Files
elwig/Elwig/Models/Delivery.cs
2023-04-27 23:34:58 +02:00

77 lines
2.0 KiB
C#

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; }
}
}