[#54] Member: Add IsJuridicalPerson
All checks were successful
Test / Run tests (push) Successful in 2m49s

This commit is contained in:
2024-08-12 15:18:34 +02:00
parent 025ff08d84
commit f48c6a02cb
37 changed files with 225 additions and 116 deletions

View File

@ -14,11 +14,14 @@ namespace Elwig.Models.Entities {
[Column("predecessor_mgnr")]
public int? PredecessorMgNr { get; set; }
[Column("name")]
public required string Name { get; set; }
[Column("prefix")]
public string? Prefix { get; set; }
[Column("given_name")]
public required string GivenName { get; set; }
public string? GivenName { get; set; }
[Column("middle_names")]
public string? MiddleName { get; set; }
@ -28,30 +31,22 @@ namespace Elwig.Models.Entities {
set => MiddleName = (value.Length > 0) ? string.Join(" ", value) : null;
}
[Column("family_name")]
public required string FamilyName { get; set; }
[Column("suffix")]
public string? Suffix { get; set; }
public string Name =>
(Prefix != null ? Prefix + " " : "") +
GivenName + " " +
(MiddleName != null ? MiddleName + " " : "") +
FamilyName +
(Suffix != null ? " " + Suffix : "");
[Column("attn")]
public string? ForTheAttentionOf { get; set; }
public string ShortName => GivenName + " " + FamilyName;
public string AdministrativeName => AdministrativeName1 + " " + AdministrativeName2;
public string AdministrativeName1 => FamilyName.Replace('ß', 'ẞ').ToUpper();
public string AdministrativeName2 =>
(Prefix != null ? Prefix + " " : "") +
GivenName +
(MiddleName != null ? " " + MiddleName : "") +
(Suffix != null ? " " + Suffix : "");
[NotMapped]
public string FullName => IsJuridicalPerson ? Name : string.Join(" ", ((string?[])[Prefix, GivenName, MiddleName, Name, Suffix]).Where(s => !string.IsNullOrWhiteSpace(s)));
[NotMapped]
public string ShortName => (!string.IsNullOrWhiteSpace(GivenName) ? $"{GivenName} " : "") + Name;
[NotMapped]
public string AdministrativeName => AdministrativeName1 + (!string.IsNullOrWhiteSpace(AdministrativeName2) ? $" {AdministrativeName2}" : "");
[NotMapped]
public string AdministrativeName1 => IsJuridicalPerson ? Name : Name.Replace('ß', 'ẞ').ToUpper();
[NotMapped]
public string? AdministrativeName2 => IsJuridicalPerson ? null : string.Join(" ", ((string?[])[Prefix, GivenName, MiddleName, Suffix]).Where(s => !string.IsNullOrWhiteSpace(s)));
[Column("birthday")]
public string? Birthday { get; set; }
@ -87,6 +82,9 @@ namespace Elwig.Models.Entities {
[Column("ustid_nr")]
public string? UstIdNr { get; set; }
[Column("juridical_pers")]
public bool IsJuridicalPerson { get; set; }
[Column("volllieferant")]
public bool IsVollLieferant { get; set; }
@ -185,8 +183,8 @@ namespace Elwig.Models.Entities {
public int SearchScore(IEnumerable<string> keywords) {
return Utils.GetSearchScore([
FamilyName, MiddleName, GivenName,
BillingAddress?.Name,
Name, MiddleName, GivenName,
BillingAddress?.FullName,
Comment,
], keywords);
}