using Microsoft.EntityFrameworkCore; using System.Collections.Generic; using System.ComponentModel.DataAnnotations.Schema; using System.Linq; namespace Elwig.Models { [Table("payment_delivery_part"), PrimaryKey("Year", "DId", "DPNr", "AvNr")] public class PaymentDeliveryPart { [Column("year")] public int Year { get; set; } [Column("did")] public int DId { get; set; } [Column("dpnr")] public int DPNr { get; set; } [Column("avnr")] public int AvNr { get; set; } [Column("mod_abs")] public long ModAbsValue { get; set; } [NotMapped] public decimal ModAbs { get => Variant.Season.DecFromDb(ModAbsValue); set => ModAbsValue = Variant.Season.DecToDb(value); } [Column("mod_rel")] public double ModRelValue { get; set; } [NotMapped] public decimal ModRel { get => (decimal)ModRelValue; set => ModRelValue = (double)value; } [Column("price_1")] public long? Price1Value { get; set; } [NotMapped] public decimal? Price1 { get => Price1Value != null ? Variant.Season.DecFromDb(Price1Value.Value) : null; set => Price1Value = value != null ? Variant.Season.DecToDb(value.Value) : null; } [Column("price_2")] public long? Price2Value { get; set; } [NotMapped] public decimal? Price2 { get => Price2Value != null ? Variant.Season.DecFromDb(Price2Value.Value) : null; set => Price2Value = value != null ? Variant.Season.DecToDb(value.Value) : null; } [Column("price_3")] public long? Price3Value { get; set; } [NotMapped] public decimal? Price3 { get => Price3Value != null ? Variant.Season.DecFromDb(Price3Value.Value) : null; set => Price3Value = value != null ? Variant.Season.DecToDb(value.Value) : null; } [Column("price_4")] public long? Price4Value { get; set; } [NotMapped] public decimal? Price4 { get => Price4Value != null ? Variant.Season.DecFromDb(Price4Value.Value) : null; set => Price4Value = value != null ? Variant.Season.DecToDb(value.Value) : null; } [Column("price_5")] public long? Price5Value { get; set; } [NotMapped] public decimal? Price5 { get => Price5Value != null ? Variant.Season.DecFromDb(Price5Value.Value) : null; set => Price5Value = value != null ? Variant.Season.DecToDb(value.Value) : null; } [Column("price_6")] public long? Price6Value { get; set; } [NotMapped] public decimal? Price6 { get => Price6Value != null ? Variant.Season.DecFromDb(Price6Value.Value) : null; set => Price6Value = value != null ? Variant.Season.DecToDb(value.Value) : null; } [Column("price_7")] public long? Price7Value { get; set; } [NotMapped] public decimal? Price7 { get => Price7Value != null ? Variant.Season.DecFromDb(Price7Value.Value) : null; set => Price7Value = value != null ? Variant.Season.DecToDb(value.Value) : null; } [Column("price_8")] public long? Price8Value { get; set; } [NotMapped] public decimal? Price8 { get => Price8Value != null ? Variant.Season.DecFromDb(Price8Value.Value) : null; set => Price8Value = value != null ? Variant.Season.DecToDb(value.Value) : null; } [Column("price_9")] public long? Price9Value { get; set; } [NotMapped] public decimal? Price9 { get => Price9Value != null ? Variant.Season.DecFromDb(Price9Value.Value) : null; set => Price9Value = value != null ? Variant.Season.DecToDb(value.Value) : null; } [Column("amount")] public long? AmountValue { get; set; } [NotMapped] public decimal? Amount { get => AmountValue != null ? Variant.Season.DecFromDb(AmountValue.Value) : null; set => AmountValue = value != null ? Variant.Season.DecToDb(value.Value) : null; } [NotMapped] public decimal[] Prices => (new decimal?[] { Price1, Price2, Price3, Price4, Price5, Price6, Price7, Price8, Price9 }) .Where(p => p != null).Select(p => p.Value).ToArray(); [ForeignKey("Year, AvNr")] public virtual PaymentVar Variant { get; private set; } [ForeignKey("Year, DId, DPNr")] public virtual DeliveryPart DeliveryPart { get; private set; } } }