Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
RegisterIdentityModel.cs
1using System.Collections.ObjectModel;
2using System.Globalization;
3using CommunityToolkit.Mvvm.ComponentModel;
4using CommunityToolkit.Mvvm.Input;
12
14{
18 public partial class RegisterIdentityModel : XmppViewModel
19 {
24 : base()
25 {
26 }
27
29 public override async Task OnInitializeAsync()
30 {
31 await base.OnInitializeAsync();
32
34 }
35
37 protected override Task XmppService_ConnectionStateChanged(object? Sender, XmppState NewState)
38 {
39 return MainThread.InvokeOnMainThreadAsync(async () =>
40 {
41 await base.XmppService_ConnectionStateChanged(Sender, NewState);
42 await this.OnConnected();
43 });
44 }
45
49 protected virtual Task OnConnected()
50 {
52 return Task.CompletedTask;
53 }
54
56 public override void SetIsBusy(bool IsBusy)
57 {
58 base.SetIsBusy(IsBusy);
60 }
61
65 protected virtual void NotifyCommandsCanExecuteChanged()
66 {
67 this.ApplyCommand.NotifyCanExecuteChanged();
68 }
69
70 public ObservableCollection<ObservableAttachmentCard> AdditionalPhotos { get; } = [];
71
75 [ObservableProperty]
76 [NotifyCanExecuteChangedFor(nameof(ApplyCommand))]
77 [NotifyPropertyChangedFor(nameof(FirstNameOk))]
78 private string? firstName = "";
79
83 [ObservableProperty]
84 [NotifyCanExecuteChangedFor(nameof(ApplyCommand))]
85 [NotifyPropertyChangedFor(nameof(MiddleNamesOk))]
86 private string? middleNames;
87
91 [ObservableProperty]
92 [NotifyCanExecuteChangedFor(nameof(ApplyCommand))]
93 [NotifyPropertyChangedFor(nameof(LastNamesOk))]
94 private string? lastNames;
95
99 [ObservableProperty]
100 [NotifyCanExecuteChangedFor(nameof(ApplyCommand))]
101 [NotifyPropertyChangedFor(nameof(PersonalNumberOk))]
102 private string? personalNumber;
103
107 [ObservableProperty]
108 [NotifyCanExecuteChangedFor(nameof(ApplyCommand))]
109 [NotifyPropertyChangedFor(nameof(AddressOk))]
110 private string? address;
111
115 [ObservableProperty]
116 [NotifyCanExecuteChangedFor(nameof(ApplyCommand))]
117 [NotifyPropertyChangedFor(nameof(Address2Ok))]
118 private string? address2;
119
123 [ObservableProperty]
124 [NotifyCanExecuteChangedFor(nameof(ApplyCommand))]
125 [NotifyPropertyChangedFor(nameof(ZipCodeOk))]
126 private string? zipCode;
127
131 [ObservableProperty]
132 [NotifyCanExecuteChangedFor(nameof(ApplyCommand))]
133 [NotifyPropertyChangedFor(nameof(AreaOk))]
134 private string? area;
135
139 [ObservableProperty]
140 [NotifyCanExecuteChangedFor(nameof(ApplyCommand))]
141 [NotifyPropertyChangedFor(nameof(CityOk))]
142 private string? city;
143
147 [ObservableProperty]
148 [NotifyCanExecuteChangedFor(nameof(ApplyCommand))]
149 [NotifyPropertyChangedFor(nameof(RegionOk))]
150 private string? region;
151
155 [ObservableProperty]
156 [NotifyCanExecuteChangedFor(nameof(ApplyCommand))]
157 [NotifyPropertyChangedFor(nameof(CountryOk))]
158 [NotifyPropertyChangedFor(nameof(PersonalNumberPlaceholder))]
159 private string? countryCode;
160
161 public string? PersonalNumberPlaceholder => string.IsNullOrEmpty(this.CountryCode) ? string.Empty: PersonalNumberSchemes.DisplayStringForCountry(this.CountryCode);
162
166 [ObservableProperty]
167 [NotifyCanExecuteChangedFor(nameof(ApplyCommand))]
168 [NotifyPropertyChangedFor(nameof(NationalityOk))]
169 private string? nationalityCode;
170
174 [ObservableProperty]
175 [NotifyCanExecuteChangedFor(nameof(ApplyCommand))]
176 [NotifyPropertyChangedFor(nameof(GenderOk))]
177 private string? genderCode;
178
183 [ObservableProperty]
184 [NotifyCanExecuteChangedFor(nameof(ApplyCommand))]
185 [NotifyPropertyChangedFor(nameof(BirthDateOk))]
186 [NotifyPropertyChangedFor(nameof(NullIfInvalidBirthDate))]
187 private DateTime birthDate = DateTime.Today;
188
192 [ObservableProperty]
193 [NotifyCanExecuteChangedFor(nameof(ApplyCommand))]
194 [NotifyPropertyChangedFor(nameof(OrgNameOk))]
195 private string? orgName;
196
200 [ObservableProperty]
201 [NotifyCanExecuteChangedFor(nameof(ApplyCommand))]
202 [NotifyPropertyChangedFor(nameof(OrgNumberOk))]
203 private string? orgNumber;
204
208 [ObservableProperty]
209 [NotifyCanExecuteChangedFor(nameof(ApplyCommand))]
210 [NotifyPropertyChangedFor(nameof(OrgAddressOk))]
211 private string? orgAddress;
212
216 [ObservableProperty]
217 [NotifyCanExecuteChangedFor(nameof(ApplyCommand))]
218 [NotifyPropertyChangedFor(nameof(OrgAddress2Ok))]
219 private string? orgAddress2;
220
224 [ObservableProperty]
225 [NotifyCanExecuteChangedFor(nameof(ApplyCommand))]
226 [NotifyPropertyChangedFor(nameof(OrgZipCodeOk))]
227 private string? orgZipCode;
228
232 [ObservableProperty]
233 [NotifyCanExecuteChangedFor(nameof(ApplyCommand))]
234 [NotifyPropertyChangedFor(nameof(OrgAreaOk))]
235 private string? orgArea;
236
240 [ObservableProperty]
241 [NotifyCanExecuteChangedFor(nameof(ApplyCommand))]
242 [NotifyPropertyChangedFor(nameof(OrgCityOk))]
243 private string? orgCity;
244
248 [ObservableProperty]
249 [NotifyCanExecuteChangedFor(nameof(ApplyCommand))]
250 [NotifyPropertyChangedFor(nameof(OrgRegionOk))]
251 private string? orgRegion;
252
256 [ObservableProperty]
257 [NotifyCanExecuteChangedFor(nameof(ApplyCommand))]
258 private string? orgCountryCode;
259
263 [ObservableProperty]
264 [NotifyCanExecuteChangedFor(nameof(ApplyCommand))]
265 [NotifyPropertyChangedFor(nameof(OrgDepartmentOk))]
266 private string? orgDepartment;
267
271 [ObservableProperty]
272 [NotifyCanExecuteChangedFor(nameof(ApplyCommand))]
273 [NotifyPropertyChangedFor(nameof(OrgRoleOk))]
274 private string? orgRole;
275
279 [ObservableProperty]
280 [NotifyCanExecuteChangedFor(nameof(ApplyCommand))]
281 private string? phoneNr;
282
286 [ObservableProperty]
287 [NotifyCanExecuteChangedFor(nameof(ApplyCommand))]
288 private string? eMail;
289
293 [ObservableProperty]
294 [NotifyCanExecuteChangedFor(nameof(ApplyCommand))]
295 private string? deviceId;
296
300 [ObservableProperty]
301 [NotifyCanExecuteChangedFor(nameof(ApplyCommand))]
302 private string? jid;
303
307 [ObservableProperty]
308 [NotifyCanExecuteChangedFor(nameof(ApplyCommand))]
309 [NotifyPropertyChangedFor(nameof(FirstNameOk))]
310 private bool requiresFirstName;
311
315 [ObservableProperty]
316 [NotifyCanExecuteChangedFor(nameof(ApplyCommand))]
317 [NotifyPropertyChangedFor(nameof(MiddleNamesOk))]
318 private bool requiresMiddleNames;
319
323 [ObservableProperty]
324 [NotifyCanExecuteChangedFor(nameof(ApplyCommand))]
325 [NotifyPropertyChangedFor(nameof(LastNamesOk))]
326 private bool requiresLastNames;
327
331 [ObservableProperty]
332 [NotifyCanExecuteChangedFor(nameof(ApplyCommand))]
333 [NotifyPropertyChangedFor(nameof(PersonalNumberOk))]
334 private bool requiresPersonalNumber;
335
339 [ObservableProperty]
340 [NotifyCanExecuteChangedFor(nameof(ApplyCommand))]
341 [NotifyPropertyChangedFor(nameof(AddressOk))]
342 private bool requiresAddress;
343
347 [ObservableProperty]
348 [NotifyCanExecuteChangedFor(nameof(ApplyCommand))]
349 [NotifyPropertyChangedFor(nameof(Address2Ok))]
350 private bool requiresAddress2;
351
355 [ObservableProperty]
356 [NotifyCanExecuteChangedFor(nameof(ApplyCommand))]
357 [NotifyPropertyChangedFor(nameof(ZipCodeOk))]
358 private bool requiresZipCode;
359
363 [ObservableProperty]
364 [NotifyCanExecuteChangedFor(nameof(ApplyCommand))]
365 [NotifyPropertyChangedFor(nameof(AreaOk))]
366 private bool requiresArea;
367
371 [ObservableProperty]
372 [NotifyCanExecuteChangedFor(nameof(ApplyCommand))]
373 [NotifyPropertyChangedFor(nameof(CityOk))]
374 private bool requiresCity;
375
379 [ObservableProperty]
380 [NotifyCanExecuteChangedFor(nameof(ApplyCommand))]
381 [NotifyPropertyChangedFor(nameof(RegionOk))]
382 private bool requiresRegion;
383
387 [ObservableProperty]
388 [NotifyCanExecuteChangedFor(nameof(ApplyCommand))]
389 [NotifyPropertyChangedFor(nameof(CountryOk))]
390 private bool requiresCountry;
391
395 [ObservableProperty]
396 [NotifyCanExecuteChangedFor(nameof(ApplyCommand))]
397 [NotifyPropertyChangedFor(nameof(CountryOk))]
398 private bool requiresCountryIso3166;
399
403 [ObservableProperty]
404 [NotifyCanExecuteChangedFor(nameof(ApplyCommand))]
405 [NotifyPropertyChangedFor(nameof(NationalityOk))]
406 private bool requiresNationality;
407
411 [ObservableProperty]
412 [NotifyCanExecuteChangedFor(nameof(ApplyCommand))]
413 [NotifyPropertyChangedFor(nameof(GenderOk))]
414 private bool requiresGender;
415
419 [ObservableProperty]
420 [NotifyCanExecuteChangedFor(nameof(ApplyCommand))]
421 [NotifyPropertyChangedFor(nameof(BirthDateOk))]
422 private bool requiresBirthDate;
423
427 [ObservableProperty]
428 [NotifyCanExecuteChangedFor(nameof(ApplyCommand))]
429 [NotifyPropertyChangedFor(nameof(OrgNameOk))]
430 private bool requiresOrgName;
431
435 [ObservableProperty]
436 [NotifyCanExecuteChangedFor(nameof(ApplyCommand))]
437 [NotifyPropertyChangedFor(nameof(OrgDepartmentOk))]
438 private bool requiresOrgDepartment;
439
443 [ObservableProperty]
444 [NotifyCanExecuteChangedFor(nameof(ApplyCommand))]
445 [NotifyPropertyChangedFor(nameof(OrgRoleOk))]
446 private bool requiresOrgRole;
447
451 [ObservableProperty]
452 [NotifyCanExecuteChangedFor(nameof(ApplyCommand))]
453 [NotifyPropertyChangedFor(nameof(OrgNumberOk))]
454 private bool requiresOrgNumber;
455
459 [ObservableProperty]
460 [NotifyCanExecuteChangedFor(nameof(ApplyCommand))]
461 [NotifyPropertyChangedFor(nameof(OrgAddressOk))]
462 private bool requiresOrgAddress;
463
467 [ObservableProperty]
468 [NotifyCanExecuteChangedFor(nameof(ApplyCommand))]
469 [NotifyPropertyChangedFor(nameof(OrgAddress2Ok))]
470 private bool requiresOrgAddress2;
471
475 [ObservableProperty]
476 [NotifyCanExecuteChangedFor(nameof(ApplyCommand))]
477 [NotifyPropertyChangedFor(nameof(OrgZipCodeOk))]
478 private bool requiresOrgZipCode;
479
483 [ObservableProperty]
484 [NotifyCanExecuteChangedFor(nameof(ApplyCommand))]
485 [NotifyPropertyChangedFor(nameof(OrgAreaOk))]
486 private bool requiresOrgArea;
487
491 [ObservableProperty]
492 [NotifyCanExecuteChangedFor(nameof(ApplyCommand))]
493 [NotifyPropertyChangedFor(nameof(OrgCityOk))]
494 private bool requiresOrgCity;
495
499 [ObservableProperty]
500 [NotifyCanExecuteChangedFor(nameof(ApplyCommand))]
501 [NotifyPropertyChangedFor(nameof(OrgRegionOk))]
502 private bool requiresOrgRegion;
503
507 [ObservableProperty]
508 [NotifyCanExecuteChangedFor(nameof(ApplyCommand))]
509 [NotifyPropertyChangedFor(nameof(OrgCountryOk))]
510 private bool requiresOrgCountry;
511
515 public bool FirstNameOk => !this.RequiresFirstName || !string.IsNullOrWhiteSpace(this.FirstName);
516
520 public bool MiddleNamesOk => !this.RequiresMiddleNames || !string.IsNullOrWhiteSpace(this.MiddleNames);
521
525 public bool LastNamesOk => !this.RequiresLastNames || !string.IsNullOrWhiteSpace(this.LastNames);
526
531 {
532 get
533 {
534 if (string.IsNullOrWhiteSpace(this.PersonalNumber))
535 return !this.RequiresPersonalNumber;
536
537 if (string.IsNullOrWhiteSpace(this.CountryCode))
538 return false;
539
540 NumberInformation Info = PersonalNumberSchemes.Validate(this.CountryCode, this.PersonalNumber).Result;
541
542 return !Info.IsValid.HasValue || Info.IsValid.Value;
543 }
544 }
545
549 public bool AddressOk => !this.RequiresAddress || !string.IsNullOrWhiteSpace(this.Address);
550
554 public bool Address2Ok => !this.RequiresAddress2 || !string.IsNullOrWhiteSpace(this.Address2);
555
559 public bool ZipCodeOk => !this.RequiresZipCode || !string.IsNullOrWhiteSpace(this.ZipCode);
560
564 public bool AreaOk => !this.RequiresArea || !string.IsNullOrWhiteSpace(this.Area);
565
569 public bool CityOk => !this.RequiresCity || !string.IsNullOrWhiteSpace(this.City);
570
574 public bool RegionOk => !this.RequiresRegion || !string.IsNullOrWhiteSpace(this.Region);
575
579 public bool CountryOk
580 {
581 get
582 {
583 if (string.IsNullOrWhiteSpace(this.CountryCode))
584 return !this.RequiresCountry;
585
586 if (this.RequiresCountryIso3166 && !ISO_3166_1.TryGetCountryByCode(this.CountryCode, out _))
587 return false;
588
589 return true;
590 }
591 }
592
596 public bool NationalityOk
597 {
598 get
599 {
600 if (string.IsNullOrWhiteSpace(this.NationalityCode))
601 return !this.RequiresNationality;
602
603 if (this.RequiresCountryIso3166 && !ISO_3166_1.TryGetCountryByCode(this.NationalityCode, out _))
604 return false;
605
606 return true;
607 }
608 }
609
613 public bool GenderOk
614 {
615 get
616 {
617 if (string.IsNullOrEmpty(this.GenderCode))
618 return !this.RequiresGender;
619
620 return ISO_5218.LetterToGender(this.GenderCode, out _);
621 }
622 }
623
627 public DateTime MaxBirthDate => DateTime.Today.AddYears(-Constants.Age.MinAge);
628
632 public DateTime MinBirthDate => DateTime.Today.AddYears(-Constants.Age.MaxAge);
633
637 public DateTime? NullIfInvalidBirthDate
638 {
639 get => (this.BirthDate == DateTime.Today) ? null : this.BirthDate;
640 set => this.BirthDate = value ?? DateTime.Today;
641 }
645 public bool BirthDateOk
646 {
647 get
648 {
649 if (this.NullIfInvalidBirthDate.HasValue && (this.BirthDate > this.MaxBirthDate || this.BirthDate < this.MinBirthDate))
650 return false;
651
652 return !this.RequiresBirthDate;
653 }
654 }
655
659 public bool OrgNameOk => !this.RequiresOrgName || !string.IsNullOrWhiteSpace(this.OrgName);
660
664 public bool OrgDepartmentOk => !this.RequiresOrgDepartment || !string.IsNullOrWhiteSpace(this.OrgDepartment);
665
669 public bool OrgRoleOk => !this.RequiresOrgRole || !string.IsNullOrWhiteSpace(this.OrgRole);
670
674 public bool OrgNumberOk => !this.RequiresOrgNumber || !string.IsNullOrEmpty(this.OrgNumber);
675
679 public bool OrgAddressOk => !this.RequiresOrgAddress || !string.IsNullOrWhiteSpace(this.OrgAddress);
680
684 public bool OrgAddress2Ok => !this.RequiresOrgAddress2 || !string.IsNullOrWhiteSpace(this.OrgAddress2);
685
689 public bool OrgZipCodeOk => !this.RequiresOrgZipCode || !string.IsNullOrWhiteSpace(this.OrgZipCode);
690
694 public bool OrgAreaOk => !this.RequiresOrgArea || !string.IsNullOrWhiteSpace(this.OrgArea);
695
699 public bool OrgCityOk => !this.RequiresOrgCity || !string.IsNullOrWhiteSpace(this.OrgCity);
700
704 public bool OrgRegionOk => !this.RequiresOrgRegion || !string.IsNullOrWhiteSpace(this.OrgRegion);
705
709 public bool OrgCountryOk
710 {
711 get
712 {
713 if (string.IsNullOrWhiteSpace(this.OrgCountryCode))
714 return !this.RequiresOrgCountry;
715
716 if (this.RequiresCountryIso3166 && !ISO_3166_1.TryGetCountryByCode(this.OrgCountryCode, out _))
717 return false;
718
719 return true;
720 }
721 }
722
728 public Property[] ToProperties(IXmppService XmppService)
729 {
730 List<Property> Properties = [];
731
732 AddProperty(Properties, Constants.XmppProperties.FirstName, this.FirstName);
733 AddProperty(Properties, Constants.XmppProperties.MiddleNames, this.MiddleNames);
734 AddProperty(Properties, Constants.XmppProperties.LastNames, this.LastNames);
735 AddProperty(Properties, Constants.XmppProperties.PersonalNumber, this.PersonalNumber);
736 AddProperty(Properties, Constants.XmppProperties.Address, this.Address);
737 AddProperty(Properties, Constants.XmppProperties.Address2, this.Address2);
738 AddProperty(Properties, Constants.XmppProperties.ZipCode, this.ZipCode);
739 AddProperty(Properties, Constants.XmppProperties.Area, this.Area);
740 AddProperty(Properties, Constants.XmppProperties.City, this.City);
741 AddProperty(Properties, Constants.XmppProperties.Region, this.Region);
742 AddProperty(Properties, Constants.XmppProperties.Country, ISO_3166_1.ToCode(this.CountryCode));
743 AddProperty(Properties, Constants.XmppProperties.Nationality, ISO_3166_1.ToCode(this.NationalityCode));
744 AddProperty(Properties, Constants.XmppProperties.Gender, this.GenderCode);
745
746 if (this.NullIfInvalidBirthDate.HasValue)
747 {
748 AddProperty(Properties, Constants.XmppProperties.BirthDay, this.NullIfInvalidBirthDate.Value.Day.ToString(CultureInfo.InvariantCulture));
749 AddProperty(Properties, Constants.XmppProperties.BirthMonth, this.NullIfInvalidBirthDate.Value.Month.ToString(CultureInfo.InvariantCulture));
750 AddProperty(Properties, Constants.XmppProperties.BirthYear, this.NullIfInvalidBirthDate.Value.Year.ToString(CultureInfo.InvariantCulture));
751 }
752
753 AddProperty(Properties, Constants.XmppProperties.OrgName, this.OrgName);
754 AddProperty(Properties, Constants.XmppProperties.OrgNumber, this.OrgNumber);
755 AddProperty(Properties, Constants.XmppProperties.OrgDepartment, this.OrgDepartment);
756 AddProperty(Properties, Constants.XmppProperties.OrgRole, this.OrgRole);
757 AddProperty(Properties, Constants.XmppProperties.OrgAddress, this.OrgAddress);
758 AddProperty(Properties, Constants.XmppProperties.OrgAddress2, this.OrgAddress2);
759 AddProperty(Properties, Constants.XmppProperties.OrgZipCode, this.OrgZipCode);
760 AddProperty(Properties, Constants.XmppProperties.OrgArea, this.OrgArea);
761 AddProperty(Properties, Constants.XmppProperties.OrgCity, this.OrgCity);
762 AddProperty(Properties, Constants.XmppProperties.OrgRegion, this.OrgRegion);
763 AddProperty(Properties, Constants.XmppProperties.OrgCountry, ISO_3166_1.ToCode(this.OrgCountryCode));
764 AddProperty(Properties, Constants.XmppProperties.Phone, this.PhoneNr);
765 AddProperty(Properties, Constants.XmppProperties.EMail, this.EMail);
766 AddProperty(Properties, Constants.XmppProperties.DeviceId, this.DeviceId);
767 AddProperty(Properties, Constants.XmppProperties.Jid, XmppService.BareJid);
768
769 return [.. Properties];
770 }
771
772 private static void AddProperty(List<Property> Properties, string PropertyName, string? PropertyValue)
773 {
774 string? s = PropertyValue?.Trim();
775
776 if (!string.IsNullOrWhiteSpace(s))
777 Properties.Add(new Property(PropertyName, s));
778 }
779
788 protected virtual Task SetProperties(LegalIdentity Identity, bool ClearPropertiesNotFound, bool SetPersonalProperties,
789 bool SetOrganizationalProperties, bool SetAppProperties)
790 {
791 if (ClearPropertiesNotFound)
792 {
793 this.FirstName = string.Empty;
794 this.MiddleNames = string.Empty;
795 this.LastNames = string.Empty;
796 this.PersonalNumber = string.Empty;
797 this.Address = string.Empty;
798 this.Address2 = string.Empty;
799 this.ZipCode = string.Empty;
800 this.Area = string.Empty;
801 this.City = string.Empty;
802 this.Region = string.Empty;
803 this.CountryCode = string.Empty;
804 this.NationalityCode = string.Empty;
805 this.GenderCode = string.Empty;
806 this.BirthDate = DateTime.Today;
807 this.OrgName = string.Empty;
808 this.OrgNumber = string.Empty;
809 this.OrgAddress = string.Empty;
810 this.OrgAddress2 = string.Empty;
811 this.OrgZipCode = string.Empty;
812 this.OrgArea = string.Empty;
813 this.OrgCity = string.Empty;
814 this.OrgRegion = string.Empty;
815 this.OrgCountryCode = string.Empty;
816 this.OrgDepartment = string.Empty;
817 this.OrgRole = string.Empty;
818 this.PhoneNr = string.Empty;
819 this.EMail = string.Empty;
820 this.DeviceId = string.Empty;
821 this.Jid = string.Empty;
822 }
823
824 int? BirthDay = null;
825 int? BirthMonth = null;
826 int? BirthYear = null;
827
828 foreach (Property P in Identity.Properties)
829 {
830 switch (P.Name)
831 {
833 if (SetPersonalProperties)
834 this.FirstName = P.Value;
835 break;
836
838 if (SetPersonalProperties)
839 this.MiddleNames = P.Value;
840 break;
841
843 if (SetPersonalProperties)
844 this.LastNames = P.Value;
845 break;
846
848 if (SetPersonalProperties)
849 this.PersonalNumber = P.Value;
850 break;
851
853 if (SetPersonalProperties)
854 this.Address = P.Value;
855 break;
856
858 if (SetPersonalProperties)
859 this.Address2 = P.Value;
860 break;
861
863 if (SetPersonalProperties)
864 this.ZipCode = P.Value;
865 break;
866
868 if (SetPersonalProperties)
869 this.Area = P.Value;
870 break;
871
873 if (SetPersonalProperties)
874 this.City = P.Value;
875 break;
876
878 if (SetPersonalProperties)
879 this.Region = P.Value;
880 break;
881
883 if (SetPersonalProperties)
884 this.CountryCode = P.Value;
885 break;
886
888 if (SetPersonalProperties)
889 this.NationalityCode = P.Value;
890 break;
891
893 if (SetPersonalProperties)
894 this.GenderCode = P.Value;
895 break;
896
898 if (int.TryParse(P.Value, out int i))
899 BirthDay = i;
900 break;
901
903 if (int.TryParse(P.Value, out i))
904 BirthMonth = i;
905 break;
906
908 if (int.TryParse(P.Value, out i))
909 BirthYear = i;
910 break;
911
913 if (SetOrganizationalProperties)
914 this.OrgName = P.Value;
915 break;
916
918 if (SetOrganizationalProperties)
919 this.OrgNumber = P.Value;
920 break;
921
923 if (SetOrganizationalProperties)
924 this.OrgRole = P.Value;
925 break;
926
928 if (SetOrganizationalProperties)
929 this.OrgDepartment = P.Value;
930 break;
931
933 if (SetOrganizationalProperties)
934 this.OrgAddress = P.Value;
935 break;
936
938 if (SetOrganizationalProperties)
939 this.OrgAddress2 = P.Value;
940 break;
941
943 if (SetOrganizationalProperties)
944 this.OrgZipCode = P.Value;
945 break;
946
948 if (SetOrganizationalProperties)
949 this.OrgArea = P.Value;
950 break;
951
953 if (SetOrganizationalProperties)
954 this.OrgCity = P.Value;
955 break;
956
958 if (SetOrganizationalProperties)
959 this.OrgRegion = P.Value;
960 break;
961
963 if (SetOrganizationalProperties)
964 this.OrgCountryCode = P.Value;
965 break;
966
968 this.DeviceId = P.Value;
969 break;
970
972 this.Jid = P.Value;
973 break;
974
976 this.PhoneNr = P.Value;
977 break;
978
980 this.EMail = P.Value;
981 break;
982 }
983 }
984
985 if (SetPersonalProperties && BirthDay.HasValue && BirthMonth.HasValue && BirthYear.HasValue)
986 {
987 try
988 {
989 this.BirthDate = new DateTime(BirthYear.Value, BirthMonth.Value, BirthDay.Value);
990 }
991 catch (Exception ex)
992 {
993 ServiceRef.LogService.LogException(ex);
994 this.BirthDate = DateTime.Today;
995 }
996 }
997
998 if (SetAppProperties)
999 {
1000 this.DeviceId = ServiceRef.PlatformSpecific.GetDeviceId();
1001 this.Jid = ServiceRef.XmppService.BareJid;
1002 this.PhoneNr = ServiceRef.TagProfile.PhoneNumber;
1003 this.EMail = ServiceRef.TagProfile.EMail;
1004 }
1005
1006 return Task.CompletedTask;
1007 }
1008
1012 public virtual bool CanExecuteCommands => !this.IsBusy;
1013
1017 public virtual bool CanApply => false;
1018
1022 [RelayCommand(CanExecute = nameof(CanApply))]
1023 protected virtual Task Apply()
1024 {
1025 return Task.CompletedTask; // Do nothing by default.
1026 }
1027
1028 }
1029}
Age-related constants.
Definition: Constants.cs:896
const int MinAge
Minimum age for applying for an ID
Definition: Constants.cs:900
const int MaxAge
Maximum age for applying for an ID
Definition: Constants.cs:905
const string PersonalNumber
Personal number
Definition: Constants.cs:394
const string OrgAddress2
Organization Address line 2
Definition: Constants.cs:474
const string OrgArea
Organization Area
Definition: Constants.cs:479
const string OrgRegion
Organization Region
Definition: Constants.cs:494
const string Nationality
Nationality
Definition: Constants.cs:434
const string BirthYear
Birth Year
Definition: Constants.cs:454
const string OrgCity
Organization City
Definition: Constants.cs:484
const string OrgRole
Organization Role
Definition: Constants.cs:509
const string Phone
Phone number
Definition: Constants.cs:524
const string EMail
e-Mail address
Definition: Constants.cs:529
const string OrgZipCode
Organization Zip Code
Definition: Constants.cs:489
const string MiddleNames
Middle names
Definition: Constants.cs:379
const string OrgCountry
Organization Country
Definition: Constants.cs:499
const string OrgDepartment
Organization Department
Definition: Constants.cs:504
const string Address2
Address line 2
Definition: Constants.cs:404
const string OrgAddress
Organization Address line 1
Definition: Constants.cs:469
const string Address
Address line 1
Definition: Constants.cs:399
const string LastNames
Last names
Definition: Constants.cs:384
const string OrgNumber
Organization number
Definition: Constants.cs:464
const string BirthMonth
Birth Month
Definition: Constants.cs:449
const string FirstName
First name
Definition: Constants.cs:374
const string OrgName
Organization name
Definition: Constants.cs:459
A set of never changing property constants and helpful values.
Definition: Constants.cs:24
Conversion between Country Names and ISO-3166-1 country codes.
Definition: ISO_3166_1.cs:10
static bool TryGetCountryByCode(string? CountryCode, [NotNullWhen(true)] out ISO_3166_Country? Country)
Tries to get the country, given its country code.
Definition: ISO_3166_1.cs:71
static ? string ToCode(string? CountryName)
Converts the name to a country code (if found). If not found, returns the original name.
Definition: ISO_3166_1.cs:113
Static class containing ISO 5218 gender codes
Definition: ISO_5218.cs:9
static bool LetterToGender(string Letter, out ISO_5218_Gender? Gender)
Tries to get the gender label corresponding to an ISO 5218 gender code.
Definition: ISO_5218.cs:40
bool? IsValid
true = valid: PersonalNumber may be normalized. false = invalid null = scheme not applicable,...
Personal Number Schemes available in different countries.
static ? string DisplayStringForCountry(string CountryCode)
Gets the expected personal number format for the given country.
static async Task< NumberInformation > Validate(string CountryCode, string PersonalNumber)
Checks if a personal number is valid, in accordance with registered personal number schemes.
Base class that references services in the app.
Definition: ServiceRef.cs:43
static ILogService LogService
Log service.
Definition: ServiceRef.cs:214
static ITagProfile TagProfile
TAG Profile service.
Definition: ServiceRef.cs:202
static IXmppService XmppService
The XMPP service for XMPP communication.
Definition: ServiceRef.cs:190
static IPlatformSpecific PlatformSpecific
Localization service
Definition: ServiceRef.cs:383
RegisterIdentityModel()
The data model for registering an identity.
Property[] ToProperties(IXmppService XmppService)
Converts the RegisterIdentityModel to an array of .
DateTime MinBirthDate
Minimum birth date. (i.e. Maximum age.)
override void SetIsBusy(bool IsBusy)
Sets the IsBusy property.
override async Task OnInitializeAsync()
Method called when view is initialized for the first time. Use this method to implement registration ...
virtual void NotifyCommandsCanExecuteChanged()
Updates status of commands.
virtual bool CanApply
If user can apply for an identity.
virtual Task SetProperties(LegalIdentity Identity, bool ClearPropertiesNotFound, bool SetPersonalProperties, bool SetOrganizationalProperties, bool SetAppProperties)
Sets the properties of the view model.
virtual Task Apply()
Executes the application command.
DateTime MaxBirthDate
Maximum birth date. (i.e. Minimum age.)
DateTime? NullIfInvalidBirthDate
Returns null if birth date is the minimum birth date. Else returns BirthDate.
override Task XmppService_ConnectionStateChanged(object? Sender, XmppState NewState)
Listens to connection state changes from the XMPP server.
virtual Task OnConnected()
Gets called when the app gets connected.
virtual bool CanExecuteCommands
Used to find out if a command can execute
A view model that holds the XMPP state.
string? GetDeviceId()
Gets the ID of the device
Represents an abstraction of a connection to an XMPP Server.
Definition: IXmppService.cs:45
string BareJid
The Bare Jid of the current connection, or null.
Definition: IXmppService.cs:82
Definition: ImplTypes.g.cs:58
XmppState
State of XMPP connection.
Definition: XmppState.cs:7