-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathApplicantAddress.cs
More file actions
66 lines (57 loc) · 1.94 KB
/
ApplicantAddress.cs
File metadata and controls
66 lines (57 loc) · 1.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
using System;
using System.Linq;
using System.Text.Json.Serialization;
using Unity.GrantManager.GrantApplications;
using Volo.Abp.Domain.Entities.Auditing;
using Volo.Abp.MultiTenancy;
namespace Unity.GrantManager.Applications;
public class ApplicantAddress : AuditedAggregateRoot<Guid>, IMultiTenant
{
public Guid? ApplicantId { get; set; }
[JsonIgnore]
public virtual Applicant Applicant
{
set => _applicant = value;
get => _applicant
?? throw new InvalidOperationException("Uninitialized property: " + nameof(Applicant));
}
private Applicant? _applicant;
public Guid? ApplicationId { get; set; }
[JsonIgnore]
public virtual Application Application
{
set => _application = value;
get => _application
?? throw new InvalidOperationException("Uninitialized property: " + nameof(Application));
}
private Application? _application;
public string? City { get; set; } = string.Empty;
public string? Country { get; set; } = string.Empty;
public string? Province { get; set; } = string.Empty;
public string? Postal { get; set; } = string.Empty;
public string? Street { get; set; } = string.Empty;
public string? Street2 { get; set; } = string.Empty;
public string? Unit { get; set; } = string.Empty;
public AddressType AddressType { get; set; } = AddressType.PhysicalAddress;
public Guid? TenantId { get; set; }
/// <summary>
/// Returns the address as a single comma-separated string, ordered by relevance.
/// </summary>
public string GetFullAddress()
{
var parts = new[]
{
Street,
Street2,
Unit,
City,
Province,
Postal,
Country
};
var address = string.Join(", ", parts
.Where(p => !string.IsNullOrWhiteSpace(p))
.Select(p => p!.Trim()));
return address;
}
}