Add BillingAddress

This commit is contained in:
2023-03-18 11:40:37 +01:00
parent b637b756d6
commit 731df99c72
4 changed files with 53 additions and 1 deletions

View File

@ -5,6 +5,7 @@ namespace Elwig.Helpers {
public class AppDbContext : DbContext { public class AppDbContext : DbContext {
public DbSet<Country> Countries { get; set; } public DbSet<Country> Countries { get; set; }
public DbSet<Member> Members { get; set; } public DbSet<Member> Members { get; set; }
public DbSet<BillingAddress> BillingAddresses { get; set; }
public DbSet<AT_Gem> Gemeinden { get; set; } public DbSet<AT_Gem> Gemeinden { get; set; }
public DbSet<AT_Kg> Katastralgemeinden { get; set; } public DbSet<AT_Kg> Katastralgemeinden { get; set; }
public DbSet<AT_Ort> Orte { get; set; } public DbSet<AT_Ort> Orte { get; set; }
@ -23,6 +24,7 @@ namespace Elwig.Helpers {
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) {
optionsBuilder.UseSqlite("Data Source=\"C:\\Users\\lorenz\\Desktop\\wgprod.sqlite3\"; foreign keys=true"); optionsBuilder.UseSqlite("Data Source=\"C:\\Users\\lorenz\\Desktop\\wgprod.sqlite3\"; foreign keys=true");
optionsBuilder.UseLazyLoadingProxies(); optionsBuilder.UseLazyLoadingProxies();
base.OnConfiguring(optionsBuilder);
} }
} }
} }

View File

@ -0,0 +1,31 @@
using Microsoft.EntityFrameworkCore;
using System.ComponentModel.DataAnnotations.Schema;
namespace Elwig.Models {
[Table("member_billing_address"), PrimaryKey("MgNr")]
public class BillingAddress {
[Column("mgnr")]
public int MgNr { get; set; }
[Column("name")]
public string Name { get; set; }
[Column("country")]
public string CountryCode { get; set; }
[Column("postal_dest")]
public string PostalDestId { get; set; }
[Column("address")]
public string Address { get; set; }
[ForeignKey("MgNr")]
public virtual Member Member { get; private set; }
[ForeignKey("CountryCode")]
public virtual Country Country { get; private set; }
[ForeignKey("CountryCode, PostalDestId")]
public virtual PostalDest PostalDest { get; private set; }
}
}

View File

@ -122,5 +122,8 @@ namespace Elwig.Models {
[InverseProperty("Member")] [InverseProperty("Member")]
public virtual ISet<Contract> Contracts { get; private set; } public virtual ISet<Contract> Contracts { get; private set; }
[InverseProperty("Member")]
public virtual BillingAddress BillingAddress { get; private set; }
} }
} }

View File

@ -390,7 +390,23 @@ namespace Elwig.Windows {
LfbisNrInput.Text = m.LfbisNr; LfbisNrInput.Text = m.LfbisNr;
BuchführendInput.IsChecked = m.IsBuchführend; BuchführendInput.IsChecked = m.IsBuchführend;
// TODO Rechnungsadresse var billingAddr = m.BillingAddress;
if (billingAddr != null) {
BillingName.Text = billingAddr.Name;
BillingAddressInput.Text = billingAddr.Address;
AT_PlzDest? b = billingAddr.PostalDest.AtPlz;
if (b != null) {
BillingPlzInput.Text = b.Plz.ToString();
BillingOrtInput.ItemsSource = b.AtPlz.Orte;
BillingOrtInput.SelectedItem = b;
}
} else {
BillingName.Text = "";
BillingAddressInput.Text = "";
BillingPlzInput.Text = "";
BillingOrtInput.ItemsSource = null;
BillingOrtInput.SelectedItem = null;
}
EntryDateInput.Text = (m.EntryDate != null) ? string.Join(".", m.EntryDate.Split("-").Reverse()) : null; EntryDateInput.Text = (m.EntryDate != null) ? string.Join(".", m.EntryDate.Split("-").Reverse()) : null;
ExitDateInput.Text = (m.ExitDate != null) ? string.Join(".", m.ExitDate.Split("-").Reverse()) : null; ExitDateInput.Text = (m.ExitDate != null) ? string.Join(".", m.ExitDate.Split("-").Reverse()) : null;