Fix Models with PLZ

This commit is contained in:
2023-03-14 11:12:19 +01:00
parent 76b1a3de75
commit b5f6adc41c
19 changed files with 69 additions and 123 deletions

View File

@ -1,11 +1,5 @@
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WGneu.Helpers;
namespace WGneu.Models {
[Table("postal_dest"), PrimaryKey("CountryCode", "Id")]
@ -19,10 +13,7 @@ namespace WGneu.Models {
[ForeignKey("CountryCode")]
public virtual Country Country { get; set; }
public AT_Plz? Plz(AppDbContext ctx) {
// TODO getter
if (CountryCode != "AT") return null;
return ctx.Postleitzahlen.Where(p => p.Id == Id).FirstOrDefault();
}
[ForeignKey("Id")]
public virtual AT_PlzDest? AtPlz { get; set; }
}
}