Refactored organisation entities and endpoints

This commit is contained in:
2026-10-04 10:11:28 +02:00
parent 8fed46961a
commit 5fb67df9ac
17 changed files with 2664 additions and 20 deletions
@@ -5,6 +5,8 @@ namespace PostFundManagement.Domain.Entities;
[EntityTypeConfiguration<OrganisationConfiguration, Organisation>]
public class Organisation : Models.Organisation
{
public virtual User? User { get; set; }
public virtual User? Creator { get; set; }
}
@@ -16,6 +18,7 @@ public sealed class OrganisationConfiguration : IEntityTypeConfiguration<Organis
builder.HasKey(pk => pk.Id);
builder.Property(f => f.CreatedBy).IsRequired();
builder.Property(f => f.UserId).IsRequired(false);
builder.Property(f => f.CreatedAt).IsRequired().HasDefaultValueSql("now()");
builder.Property(f => f.RegistrationNo).IsRequired().HasMaxLength(LabelLength);
builder.Property(f => f.Name).IsRequired().HasMaxLength(LabelLength);
@@ -25,6 +28,12 @@ public sealed class OrganisationConfiguration : IEntityTypeConfiguration<Organis
builder.Property(f => f.Status).IsRequired().HasConversion<int>().HasDefaultValueSql("1")
.HasSentinel(ActivityStatus.Active);
builder.HasOne(f => f.User)
.WithMany()
.HasForeignKey(fk => fk.UserId)
.IsRequired(false)
.OnDelete(DeleteBehavior.NoAction);
builder.HasOne(f => f.Creator)
.WithMany()
.HasForeignKey(fk => fk.CreatedBy)
@@ -14,6 +14,7 @@ public sealed class UserConfiguration : IEntityTypeConfiguration<User>
builder.HasKey(pk => pk.Id);
builder.Property(f => f.Email).IsRequired().HasMaxLength(LabelLength);
builder.Property(f => f.Role).IsRequired(false).HasMaxLength(LabelLength);
builder.Property(f => f.IdNumber).IsRequired(false).HasMaxLength(LabelLength);
builder.Property(f => f.Status).IsRequired().HasConversion<int>().HasDefaultValueSql("2")
.HasSentinel(ActivityStatus.Inactive);
builder.Property(f => f.LastLoginAt).IsRequired(false);
@@ -11,7 +11,7 @@ public static class Mappers
CreatedAt = entity.CreatedAt,
CreatedBy = entity.CreatedBy,
Status = entity.Status,
UserId = entity.UserId
UserId = entity.UserId
};
public static TenantOrganisation Map(this Entities.TenantOrganisation entity) => new()
@@ -21,7 +21,7 @@ public static class Mappers
CreatedAt = entity.CreatedAt,
CreatedBy = entity.CreatedBy,
OrganisationId = entity.OrganisationId,
TenantId = entity.TenantId
TenantId = entity.TenantId
};
public static Tenant Map(this Entities.Tenant entity) => new()
@@ -32,7 +32,7 @@ public static class Mappers
CreatedBy = entity.CreatedBy,
Status = entity.Status,
UpdatedAt = entity.UpdatedAt,
UpdatedBy = entity.UpdatedBy
UpdatedBy = entity.UpdatedBy
};
public static Activity Map(this Entities.Activity entity) => new()
@@ -270,7 +270,8 @@ public static class Mappers
Name = entity.Name,
RegistrationNo = entity.RegistrationNo,
Status = entity.Status,
Type = entity.Type
Type = entity.Type,
UserId = entity.UserId
};
public static Outcome Map(this Entities.Outcome entity) => new()
@@ -392,6 +393,7 @@ public static class Mappers
Email = entity.Email,
LastLoginAt = entity.LastLoginAt,
Status = entity.Status,
Role = entity.Role
Role = entity.Role,
IdNumber = entity.IdNumber
};
}
@@ -14,6 +14,8 @@ public class Organisation
public string? Email { get; set; }
public Guid? UserId { get; set; }
public OrganisationType Type { get; set; }
public ActivityStatus Status { get; set; }
+2
View File
@@ -10,5 +10,7 @@ public class User
public string? Role { get; set; }
public string? IdNumber { get; set; }
public ActivityStatus Status { get; set; }
}