Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added insert scripts for DMS Establishment Code and Org Code mapping … #56

Merged
merged 3 commits into from
Jul 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
235 changes: 235 additions & 0 deletions db/seed/001_development_seed.sql

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions src/Domain/Entities/Administration/Location.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ public class Location : BaseAuditableEntity<int>, ILifetime
private Lifetime _lifetime;
private int? _parentLocationId;
private readonly List<Location> _childLocations = new();
private List<LocationMapping> _locationMappings = new();


#pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable.
private Location()
{
Expand Down Expand Up @@ -57,7 +57,7 @@ public static Location Create(string name, int genderProvisionId, int locationTy

public IReadOnlyCollection<Location> ChildLocations => _childLocations.AsReadOnly();


public IReadOnlyCollection<LocationMapping> LocationMappings => _locationMappings.AsReadOnly();

public void AddChildLocation(Location child)
{
Expand Down
23 changes: 23 additions & 0 deletions src/Domain/Entities/Administration/LocationMapping.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using System.ComponentModel.DataAnnotations.Schema;
using System.Runtime.InteropServices;
using System.Xml.Linq;
using Cfo.Cats.Domain.Common.Contracts;
using Cfo.Cats.Domain.Common.Entities;
using Cfo.Cats.Domain.Common.Enums;
using Cfo.Cats.Domain.Events;
using Cfo.Cats.Domain.ValueObjects;

namespace Cfo.Cats.Domain.Entities.Administration;
public class LocationMapping
{
#pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable.
private LocationMapping()
{
}
#pragma warning restore CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable.
public string Code { get; set; }
public string CodeType { get; set; }
public string Description { get; set; }
public string DeliveryRegion { get; set; }
public virtual Location? Location { get; private set; }
}
5 changes: 5 additions & 0 deletions src/Infrastructure/Constants/Database/DatabaseSchema.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public static class Tables
public const string Contract = nameof(Contract);
public const string Document = nameof(Document);
public const string Location = nameof(Location);
public const string LocationMapping = nameof(LocationMapping);
public const string Participant = nameof(Participant);
public const string ParticipantAssessment = nameof(ParticipantAssessment);
public const string Tenant = nameof(Tenant);
Expand All @@ -32,6 +33,10 @@ public static class Tables
public const string Timeline = nameof(Timeline);

}
public static class Schema
{
public const string dms = nameof(dms);
}

}

Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
using Cfo.Cats.Domain.Entities.Administration;
using Cfo.Cats.Infrastructure.Constants.Database;
using Microsoft.EntityFrameworkCore.Metadata.Builders;

namespace Cfo.Cats.Infrastructure.Persistence.Configurations;

public class LocationMappingEntityTypeConfiguration : IEntityTypeConfiguration<LocationMapping>
{
public void Configure(EntityTypeBuilder<LocationMapping> builder)
{

builder.ToTable(
DatabaseSchema.Tables.LocationMapping,
DatabaseSchema.Schema.dms
);



// Configure the primary key
builder.HasKey(l => new { l.Code, l.CodeType });

// Configure properties
builder.Property(c => c.Code)
.HasMaxLength(3);

builder.Property(c => c.CodeType)
.HasMaxLength(9);

builder.Property(l => l.Description)
.HasMaxLength(200);// Adjust the length as needed
builder.Property(l => l.DeliveryRegion)
.HasMaxLength(200)
.IsRequired(false); ;// Adjust the length as needed


// Configure the optional relationship with Location
builder.HasOne(l => l.Location)
.WithMany(c => c.LocationMappings)
.HasForeignKey("_locationId");

builder.Property("_locationId")
.HasColumnName("LocationId")
.IsRequired(false);

}
}
Loading
Loading