Dtos: Unify member names in DataTables

This commit is contained in:
2024-03-27 16:41:08 +01:00
parent d87f3ce6a6
commit 57662534f3
5 changed files with 58 additions and 46 deletions

View File

@ -9,8 +9,8 @@ namespace Elwig.Models.Dtos {
private static readonly (string, string, string?, int)[] FieldNames = [
("MgNr", "MgNr.", null, 12),
("Name", "Name", null, 40),
("GivenName", "Vorname", null, 40),
("Name1", "Name", null, 40),
("Name2", "Vorname", null, 40),
("Address", "Adresse", null, 60),
("Plz", "PLZ", null, 10),
("Locality", "Ort", null, 60),
@ -35,7 +35,10 @@ namespace Elwig.Models.Dtos {
private static async Task<IEnumerable<AreaComUnderDeliveryRowSingle>> FromDbSet(DbSet<AreaComUnderDeliveryRowSingle> table, int year) {
return await table.FromSqlRaw($"""
SELECT m.mgnr, m.family_name, m.given_name, p.plz, o.name AS ort, m.address,
SELECT m.mgnr, m.family_name AS name_1,
COALESCE(m.prefix || ' ', '') || m.given_name ||
COALESCE(' ' || m.middle_names, '') || COALESCE(' ' || m.suffix, '') AS name_2,
p.plz, o.name AS ort, m.address,
c.bucket, c.area, u.min_kg, u.weight
FROM member m
LEFT JOIN AT_plz_dest p ON p.id = m.postal_dest
@ -50,8 +53,8 @@ namespace Elwig.Models.Dtos {
public class AreaComUnderDeliveryRow {
public int MgNr;
public string Name;
public string GivenName;
public string Name1;
public string Name2;
public string Address;
public int Plz;
public string Locality;
@ -66,8 +69,8 @@ namespace Elwig.Models.Dtos {
public AreaComUnderDeliveryRow(IEnumerable<AreaComUnderDeliveryRowSingle> rows) {
var f = rows.First();
MgNr = f.MgNr;
Name = f.Name;
GivenName = f.GivenName;
Name1 = f.Name1;
Name2 = f.Name2;
Address = f.Address;
Plz = f.Plz;
Locality = f.Locality.Split(",")[0];
@ -82,10 +85,10 @@ namespace Elwig.Models.Dtos {
public class AreaComUnderDeliveryRowSingle {
[Column("mgnr")]
public int MgNr { get; set; }
[Column("family_name")]
public required string Name { get; set; }
[Column("given_name")]
public required string GivenName { get; set; }
[Column("name_1")]
public required string Name1 { get; set; }
[Column("name_2")]
public required string Name2 { get; set; }
[Column("address")]
public required string Address { get; set; }
[Column("plz")]