Models: Add payment_member
This commit is contained in:
@ -43,6 +43,7 @@ namespace Elwig.Helpers {
|
||||
public DbSet<DeliveryPartAttr> DeliveryPartAttributes { get; private set; }
|
||||
public DbSet<DeliveryPartModifier> DeliveryPartModifiers { get; private set; }
|
||||
public DbSet<PaymentVar> PaymentVariants { get; private set; }
|
||||
public DbSet<PaymentMember> MemberPayments { get; private set; }
|
||||
|
||||
private readonly StreamWriter? LogFile = null;
|
||||
public static DateTime LastWriteTime => File.GetLastWriteTime(App.Config.DatabaseFile);
|
||||
|
@ -19,12 +19,8 @@ namespace Elwig.Models {
|
||||
|
||||
[NotMapped]
|
||||
public DateOnly Date {
|
||||
get {
|
||||
return DateOnly.ParseExact(DateString, "yyyy-MM-dd");
|
||||
}
|
||||
set {
|
||||
DateString = value.ToString("yyyy-MM-dd");
|
||||
}
|
||||
get => DateOnly.ParseExact(DateString, "yyyy-MM-dd");
|
||||
set => DateString = value.ToString("yyyy-MM-dd");
|
||||
}
|
||||
|
||||
[Column("time")]
|
||||
@ -32,19 +28,13 @@ namespace Elwig.Models {
|
||||
|
||||
[NotMapped]
|
||||
public TimeOnly? Time {
|
||||
get {
|
||||
return (TimeString == null) ? null : TimeOnly.ParseExact(TimeString, "HH:mm:ss");
|
||||
}
|
||||
set {
|
||||
TimeString = value?.ToString("HH:mm:ss");
|
||||
}
|
||||
get => (TimeString == null) ? null : TimeOnly.ParseExact(TimeString, "HH:mm:ss");
|
||||
set => TimeString = value?.ToString("HH:mm:ss");
|
||||
}
|
||||
|
||||
[NotMapped]
|
||||
public DateTime DateTime {
|
||||
get {
|
||||
return Date.ToDateTime(Time ?? TimeOnly.MinValue);
|
||||
}
|
||||
get => Date.ToDateTime(Time ?? TimeOnly.MinValue);
|
||||
set {
|
||||
Date = DateOnly.FromDateTime(value);
|
||||
Time = TimeOnly.FromDateTime(value);
|
||||
@ -72,6 +62,9 @@ namespace Elwig.Models {
|
||||
[Column("comment")]
|
||||
public string? Comment { get; set; }
|
||||
|
||||
[ForeignKey("Year")]
|
||||
public virtual Season Season { get; private set; }
|
||||
|
||||
[InverseProperty("Delivery")]
|
||||
public virtual ISet<DeliveryPart> Parts { get; private set; }
|
||||
|
||||
|
31
Elwig/Models/PaymentMember.cs
Normal file
31
Elwig/Models/PaymentMember.cs
Normal file
@ -0,0 +1,31 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace Elwig.Models {
|
||||
[Table("payment_member"), PrimaryKey("Year", "AvNr", "MgNr")]
|
||||
public class PaymentMember {
|
||||
[Column("year")]
|
||||
public int Year { get; set; }
|
||||
|
||||
[Column("avnr")]
|
||||
public int AvNr { get; set; }
|
||||
|
||||
[Column("mgnr")]
|
||||
public int MgNr { get; set; }
|
||||
|
||||
[Column("amount")]
|
||||
public long AmountValue { get; set; }
|
||||
|
||||
[NotMapped]
|
||||
public decimal Amount {
|
||||
get => Variant.Season.DecFromDb(AmountValue);
|
||||
set => AmountValue = Variant.Season.DecToDb(value);
|
||||
}
|
||||
|
||||
[ForeignKey("Year, AvNr")]
|
||||
public virtual PaymentVar Variant { get; private set; }
|
||||
|
||||
[ForeignKey("MgNr")]
|
||||
public virtual Member Member { get; private set; }
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
@ -65,5 +65,8 @@ namespace Elwig.Models {
|
||||
|
||||
[Column("data")]
|
||||
public string Data { get; set; }
|
||||
|
||||
[ForeignKey("Year")]
|
||||
public virtual Season Season { get; private set; }
|
||||
}
|
||||
}
|
||||
|
@ -18,6 +18,9 @@ namespace Elwig.Models {
|
||||
|
||||
public string CommentFormat => (Comment != null) ? $" ({Comment})" : "";
|
||||
|
||||
public bool IsRed => Type == "R";
|
||||
public bool IsWhite => Type == "W";
|
||||
|
||||
public override string ToString() {
|
||||
return Name;
|
||||
}
|
||||
|
Reference in New Issue
Block a user