Update models

This commit is contained in:
2023-04-28 13:01:43 +02:00
parent 351a0b8d57
commit 3f11a498bc
6 changed files with 82 additions and 3 deletions

View File

@ -12,6 +12,7 @@ namespace Elwig.Helpers {
public DbSet<Country> Countries { get; set; }
public DbSet<Currency> Currencies { get; set; }
public DbSet<ClientParam> ClientParameters { get; set; }
public DbSet<Member> Members { get; set; }
public DbSet<BillingAddr> BillingAddresses { get; set; }
public DbSet<AT_Gem> Gemeinden { get; set; }
@ -35,6 +36,8 @@ namespace Elwig.Helpers {
public DbSet<Season> Seasons { get; set; }
public DbSet<Delivery> Deliveries { get; set; }
public DbSet<DeliveryPart> DeliveryParts { get; set; }
public DbSet<DeliveryPartAttr> DeliveryPartAttributes { get; set; }
public DbSet<DeliveryPartModifier> DeliveryPartModifiers { get; set; }
private readonly StreamWriter? LogFile = null;

View File

@ -0,0 +1,13 @@
using Microsoft.EntityFrameworkCore;
using System.ComponentModel.DataAnnotations.Schema;
namespace Elwig.Models {
[Table("client_parameter"), PrimaryKey("Param")]
public class ClientParam {
[Column("param")]
public string Param { get; set; }
[Column("value")]
public string? Value { get; set; }
}
}

View File

@ -1,6 +1,8 @@
using Elwig.Helpers;
using Microsoft.EntityFrameworkCore;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
namespace Elwig.Models {
[Table("delivery_part"), PrimaryKey("Year", "DId", "DPNr")]
@ -92,5 +94,17 @@ namespace Elwig.Models {
[Column("comment")]
public string? Comment { get; set; }
[InverseProperty("Part")]
public virtual ISet<DeliveryPartAttr> PartAttributes { get; private set; }
[NotMapped]
public IEnumerable<WineAttr> Attributes => PartAttributes.Select(a => a.Attr);
[InverseProperty("Part")]
public virtual ISet<DeliveryPartModifier> PartModifiers { get; private set; }
[NotMapped]
public IEnumerable<Modifier> Modifiiers => PartModifiers.Select(m => m.Modifier);
}
}

View File

@ -0,0 +1,25 @@
using Microsoft.EntityFrameworkCore;
using System.ComponentModel.DataAnnotations.Schema;
namespace Elwig.Models {
[Table("delivery_part_attribute"), PrimaryKey("Year", "DId", "DPNr", "AttrId")]
public class DeliveryPartAttr {
[Column("year")]
public int Year { get; set; }
[Column("did")]
public int DId { get; set; }
[Column("dpnr")]
public int DPNr { get; set; }
[ForeignKey("Year, DId, DPNr")]
public virtual DeliveryPart Part { get; private set; }
[Column("attrid")]
public string AttrId { get; set; }
[ForeignKey("AttrId")]
public virtual WineAttr Attr { get; private set; }
}
}

View File

@ -0,0 +1,25 @@
using Microsoft.EntityFrameworkCore;
using System.ComponentModel.DataAnnotations.Schema;
namespace Elwig.Models {
[Table("delivery_part_modifier"), PrimaryKey("Year", "DId", "DPNr", "ModId")]
public class DeliveryPartModifier {
[Column("year")]
public int Year { get; set; }
[Column("did")]
public int DId { get; set; }
[Column("dpnr")]
public int DPNr { get; set; }
[ForeignKey("Year, DId, DPNr")]
public virtual DeliveryPart Part { get; private set; }
[Column("modid")]
public string ModId { get; set; }
[ForeignKey("Year, ModId")]
public virtual Modifier Modifier { get; private set; }
}
}

View File

@ -165,9 +165,8 @@ namespace Elwig.Models {
public virtual ISet<Contract> Contracts { get; private set; }
[NotMapped]
public virtual ISet<Contract> ActiveContracts => Contracts
.Where(c => c.YearFrom <= Utils.CurrentSeason && (c.YearTo ?? int.MaxValue) >= Utils.CurrentSeason)
.ToHashSet();
public virtual IEnumerable<Contract> ActiveContracts => Contracts
.Where(c => c.YearFrom <= Utils.CurrentSeason && (c.YearTo ?? int.MaxValue) >= Utils.CurrentSeason);
[InverseProperty("Member")]
public virtual BillingAddr? BillingAddress { get; private set; }