-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPolicyConfiguration.cs
More file actions
119 lines (107 loc) · 4.42 KB
/
Copy pathPolicyConfiguration.cs
File metadata and controls
119 lines (107 loc) · 4.42 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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
using ClaimsModule.Domain.Enums;
using ClaimsModule.Domain.Policies;
using ClaimsModule.Persistence.Seeding;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
namespace ClaimsModule.Persistence.Configurations;
internal sealed class PolicyConfiguration : IEntityTypeConfiguration<Policy>
{
public void Configure(EntityTypeBuilder<Policy> builder)
{
builder.ToTable("Policies");
builder.HasKey(e => e.Id);
builder.Property(e => e.Id)
.ConfigureSequentialGuidKey("PolicyId");
builder.Property(e => e.OrganisationId).IsRequired();
builder.Property(e => e.PolicyNumber).HasMaxLength(50).IsRequired();
builder.Property(e => e.ClientName).HasMaxLength(255).IsRequired();
builder.Property(e => e.EffectiveDate)
.IsRequired()
.HasColumnType("date");
builder.Property(e => e.ExpirationDate)
.IsRequired()
.HasColumnType("date");
builder.Property(e => e.Status)
.HasMaxLength(50)
.IsRequired()
.HasConversion(new EnumToStringConverter<PolicyStatus>());
builder.Property(e => e.CoverageTypes)
.IsRequired()
.HasColumnType("nvarchar(max)");
builder.ConfigureAuditableColumns();
builder.ConfigureSoftDeleteColumns();
builder.HasIndex(e => e.PolicyNumber)
.IsUnique()
.HasDatabaseName("UX_Policies_PolicyNumber");
var orgId = SeedConstants.SeedOrganisationId;
var seedCreated = SeedConstants.ReferenceDataCreatedAt;
builder.HasData(
new
{
Id = new Guid("aaaaaaaa-0001-0000-0000-000000000001"),
OrganisationId = orgId,
PolicyNumber = "POL-2024-001001",
ClientName = "Meridian Transport LLC",
EffectiveDate = new DateOnly(2024, 1, 1),
ExpirationDate = new DateOnly(2026, 12, 31),
Status = PolicyStatus.Active,
CoverageTypes = "[\"Vehicle\",\"Cargo\"]",
IsDeleted = false,
CreatedAt = seedCreated
},
new
{
Id = new Guid("aaaaaaaa-0001-0000-0000-000000000002"),
OrganisationId = orgId,
PolicyNumber = "POL-2024-001002",
ClientName = "Harborview Properties Inc",
EffectiveDate = new DateOnly(2024, 6, 1),
ExpirationDate = new DateOnly(2026, 5, 31),
Status = PolicyStatus.Active,
CoverageTypes = "[\"Property\",\"Liability\"]",
IsDeleted = false,
CreatedAt = seedCreated
},
new
{
Id = new Guid("aaaaaaaa-0001-0000-0000-000000000003"),
OrganisationId = orgId,
PolicyNumber = "POL-2025-002001",
ClientName = "Coastal Builders Group",
EffectiveDate = new DateOnly(2025, 3, 1),
ExpirationDate = new DateOnly(2027, 2, 28),
Status = PolicyStatus.Active,
CoverageTypes = "[\"Property\",\"Equipment\"]",
IsDeleted = false,
CreatedAt = seedCreated
},
new
{
Id = new Guid("aaaaaaaa-0001-0000-0000-000000000004"),
OrganisationId = orgId,
PolicyNumber = "POL-2025-002002",
ClientName = "Stanton Medical Group",
EffectiveDate = new DateOnly(2025, 1, 1),
ExpirationDate = new DateOnly(2026, 12, 31),
Status = PolicyStatus.Active,
CoverageTypes = "[\"Liability\",\"Vehicle\"]",
IsDeleted = false,
CreatedAt = seedCreated
},
new
{
Id = new Guid("aaaaaaaa-0001-0000-0000-000000000005"),
OrganisationId = orgId,
PolicyNumber = "POL-2023-000099",
ClientName = "Archived Corp",
EffectiveDate = new DateOnly(2020, 1, 1),
ExpirationDate = new DateOnly(2021, 12, 31),
Status = PolicyStatus.Expired,
CoverageTypes = "[\"Property\"]",
IsDeleted = false,
CreatedAt = seedCreated
}
);
}
}