From b6afb9424680dd7d2808db3d4833fc684a4620e3 Mon Sep 17 00:00:00 2001 From: Lorenz Stechauner Date: Wed, 24 Jul 2024 19:28:34 +0200 Subject: [PATCH] MemberListData: Include contact information like phone numbers and email addresses --- Elwig/Models/Dtos/MemberListData.cs | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/Elwig/Models/Dtos/MemberListData.cs b/Elwig/Models/Dtos/MemberListData.cs index 38d344f..563927d 100644 --- a/Elwig/Models/Dtos/MemberListData.cs +++ b/Elwig/Models/Dtos/MemberListData.cs @@ -34,7 +34,11 @@ namespace Elwig.Models.Dtos { ("UstIdNr", "UID", null, 25), ("Iban", "IBAN", null, 45), ("Bic", "BIC", null, 30), - ("Comment", "Anmerkung", null, 60), + ("TelNrLandline", "Festnetz", null, 35), + ("TelNrMobile", "Mobil", null, 35), + ("EmailAddress", "E-Mail", null, 70), + ("AdditionalContact", "Weitere", null, 70), + ("Comment", "Anmerkung", null, 80), ]; public MemberListData(IEnumerable rows, List filterNames) : @@ -48,6 +52,9 @@ namespace Elwig.Models.Dtos { .Include(m => m.Branch) .Include(m => m.PostalDest.AtPlz!.Ort) .Include(m => m.BillingAddress!.PostalDest.AtPlz!.Ort) + .Include(m => m.TelephoneNumbers) + .Include(m => m.EmailAddresses) + .AsSplitQuery() .ToListAsync()).Select(m => new MemberListRow(m, areaCom[m.MgNr])), filterNames); } } @@ -76,6 +83,10 @@ namespace Elwig.Models.Dtos { public bool IsActive; public DateOnly? EntryDate; public DateOnly? ExitDate; + public string? TelNrLandline; + public string? TelNrMobile; + public string? EmailAddress; + public string? AdditionalContact; public string? Comment; public MemberListRow(Member m, int? areaCom = null) { @@ -103,6 +114,15 @@ namespace Elwig.Models.Dtos { IsActive = m.IsActive; EntryDate = m.EntryDate; ExitDate = m.ExitDate; + TelNrLandline = m.TelephoneNumbers.OrderBy(n => n.Nr).FirstOrDefault(n => n.Type == "landline")?.Number; + TelNrMobile = m.TelephoneNumbers.OrderBy(n => n.Nr).FirstOrDefault(n => n.Type == "mobile")?.Number; + EmailAddress = m.EmailAddresses.OrderBy(a => a.Nr).FirstOrDefault()?.Address; + AdditionalContact = string.Join(", ", m.TelephoneNumbers + .OrderBy(n => n.Nr) + .Select(n => n.Number) + .Except([TelNrLandline, TelNrMobile]) + .Distinct() + .Concat(m.EmailAddresses.OrderBy(a => a.Nr).Select(a => a.Address).Except([EmailAddress]))); Comment = m.Comment; AreaCommitment = areaCom == 0 ? null : areaCom; }