Add BillingAddress
This commit is contained in:
@ -5,6 +5,7 @@ namespace Elwig.Helpers {
|
||||
public class AppDbContext : DbContext {
|
||||
public DbSet<Country> Countries { get; set; }
|
||||
public DbSet<Member> Members { get; set; }
|
||||
public DbSet<BillingAddress> BillingAddresses { get; set; }
|
||||
public DbSet<AT_Gem> Gemeinden { get; set; }
|
||||
public DbSet<AT_Kg> Katastralgemeinden { get; set; }
|
||||
public DbSet<AT_Ort> Orte { get; set; }
|
||||
@ -23,6 +24,7 @@ namespace Elwig.Helpers {
|
||||
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) {
|
||||
optionsBuilder.UseSqlite("Data Source=\"C:\\Users\\lorenz\\Desktop\\wgprod.sqlite3\"; foreign keys=true");
|
||||
optionsBuilder.UseLazyLoadingProxies();
|
||||
base.OnConfiguring(optionsBuilder);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
31
Elwig/Models/BillingAddress.cs
Normal file
31
Elwig/Models/BillingAddress.cs
Normal 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; }
|
||||
}
|
||||
}
|
@ -122,5 +122,8 @@ namespace Elwig.Models {
|
||||
|
||||
[InverseProperty("Member")]
|
||||
public virtual ISet<Contract> Contracts { get; private set; }
|
||||
|
||||
[InverseProperty("Member")]
|
||||
public virtual BillingAddress BillingAddress { get; private set; }
|
||||
}
|
||||
}
|
||||
|
@ -390,7 +390,23 @@ namespace Elwig.Windows {
|
||||
LfbisNrInput.Text = m.LfbisNr;
|
||||
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;
|
||||
ExitDateInput.Text = (m.ExitDate != null) ? string.Join(".", m.ExitDate.Split("-").Reverse()) : null;
|
||||
|
Reference in New Issue
Block a user