Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
LegalIdentityExtensions.cs
2
4{
8 public static class LegalIdentityExtensions
9 {
15 public static bool IsDiscarded(this LegalIdentity Identity)
16 {
17 return Identity is null ||
18 Identity.State == IdentityState.Compromised ||
19 Identity.State == IdentityState.Obsoleted ||
20 Identity.State == IdentityState.Rejected;
21 }
22
28 public static bool IsApproved(this LegalIdentity Identity)
29 {
30 return Identity is not null && Identity.State == IdentityState.Approved;
31 }
32
38 public static bool HasApprovedPersonalInformation(this LegalIdentity? Identity)
39 {
40 if (Identity?.Attachments is null)
41 return false;
42
43 if (!Identity.IsApproved())
44 return false;
45
46 bool HasFirstName = false;
47 bool HasLastName = false;
48 bool HasPersonalNumber = false;
49
50 foreach (Property P in Identity.Properties)
51 {
52 switch (P.Name)
53 {
55 HasFirstName = true;
56 break;
57
59 HasLastName = true;
60 break;
61
63 HasPersonalNumber = true;
64 break;
65 }
66 }
67
68 if (!(HasFirstName && HasLastName && HasPersonalNumber))
69 return false;
70
71 Attachment? Photo = Identity.Attachments.GetFirstImageAttachment();
72 if (Photo is null)
73 return false;
74
75 return true;
76 }
77
84 public static string GetJid(this LegalIdentity legalIdentity, string defaultValueIfNotFound = "")
85 {
86 string? Jid = null;
87
88 if (legalIdentity is not null && legalIdentity.Properties?.Length > 0)
89 Jid = legalIdentity.Properties.FirstOrDefault(x => x.Name == Constants.XmppProperties.Jid)?.Value;
90
91 return !string.IsNullOrWhiteSpace(Jid) ? Jid : defaultValueIfNotFound;
92 }
93
99 public static bool IsOrganizational(this LegalIdentity Identity)
100 {
101 if (Identity?.Properties is null)
102 return false;
103
104 foreach (Property P in Identity.Properties)
105 {
106 switch (P.Name)
107 {
119 return true;
120 }
121 }
122
123 return false;
124 }
125
131 public static bool IsPersonal(this LegalIdentity Identity)
132 {
133 return !Identity.IsOrganizational();
134 }
135 }
136}
const string PersonalNumber
Personal number
Definition: Constants.cs:284
const string OrgAddress2
Organization Address line 2
Definition: Constants.cs:364
const string OrgArea
Organization Area
Definition: Constants.cs:369
const string OrgRegion
Organization Region
Definition: Constants.cs:384
const string OrgCity
Organization City
Definition: Constants.cs:374
const string OrgRole
Organization Role
Definition: Constants.cs:399
const string OrgZipCode
Organization Zip Code
Definition: Constants.cs:379
const string OrgCountry
Organization Country
Definition: Constants.cs:389
const string OrgDepartment
Organization Department
Definition: Constants.cs:394
const string OrgAddress
Organization Address line 1
Definition: Constants.cs:359
const string LastNames
Last names
Definition: Constants.cs:279
const string OrgNumber
Organization number
Definition: Constants.cs:354
const string FirstName
First name
Definition: Constants.cs:269
const string OrgName
Organization name
Definition: Constants.cs:349
A set of never changing property constants and helpful values.
Definition: Constants.cs:7
Contains a reference to an attachment assigned to a legal object.
Definition: Attachment.cs:9
IdentityState
Lists recognized legal identity states.