diff --git a/src/backend/api/Fusion.Resources.Database/Entities/DbContract.cs b/src/backend/api/Fusion.Resources.Database/Entities/DbContract.cs deleted file mode 100644 index 7bccc2cc4..000000000 --- a/src/backend/api/Fusion.Resources.Database/Entities/DbContract.cs +++ /dev/null @@ -1,20 +0,0 @@ -using System; - -namespace Fusion.Resources.Database.Entities -{ - public class DbContract - { - public Guid Id { get; set; } - public string ContractNumber { get; set; } = null!; - public Guid OrgContractId { get; set; } - public string Name { get; set; } = null!; - - public DbProject Project { get; set; } = null!; - public Guid ProjectId { get; set; } - - public DateTimeOffset Allocated { get; set; } - public DbPerson AllocatedBy { get; set; } = null!; - public Guid AllocatedById { get; set; } - } - -} \ No newline at end of file diff --git a/src/backend/api/Fusion.Resources.Database/Entities/DbContractPersonnel.cs b/src/backend/api/Fusion.Resources.Database/Entities/DbContractPersonnel.cs deleted file mode 100644 index e375092da..000000000 --- a/src/backend/api/Fusion.Resources.Database/Entities/DbContractPersonnel.cs +++ /dev/null @@ -1,43 +0,0 @@ -using Microsoft.EntityFrameworkCore; -using System; - -namespace Fusion.Resources.Database.Entities -{ - - public class DbContractPersonnel : ITrackableEntity - { - public Guid Id { get; set; } - - public DbContract Contract { get; set; } = null!; - public Guid ContractId { get; set; } - - public DbProject Project { get; set; } = null!; - public Guid ProjectId { get; set; } - - public DbExternalPersonnelPerson Person { get; set; } = null!; - public Guid PersonId { get; set; } - - public DateTimeOffset Created { get; set; } - public DateTimeOffset? Updated { get; set; } - public DbPerson CreatedBy { get; set; } = null!; - public DbPerson? UpdatedBy { get; set; } - - public Guid CreatedById { get; set; } - public Guid? UpdatedById { get; set; } - - - internal static void OnModelCreating(ModelBuilder modelBuilder) - { - modelBuilder.Entity(entity => - { - entity.HasOne(e => e.Contract).WithMany().OnDelete(DeleteBehavior.Restrict); - entity.HasOne(e => e.Project).WithMany().OnDelete(DeleteBehavior.Restrict); - - entity.HasOne(e => e.CreatedBy).WithMany().OnDelete(DeleteBehavior.Restrict); - entity.HasOne(e => e.UpdatedBy).WithMany().OnDelete(DeleteBehavior.Restrict); - }); - - } - } - -} diff --git a/src/backend/api/Fusion.Resources.Database/Entities/DbContractPersonnelReplacement.cs b/src/backend/api/Fusion.Resources.Database/Entities/DbContractPersonnelReplacement.cs deleted file mode 100644 index 8c63cc78b..000000000 --- a/src/backend/api/Fusion.Resources.Database/Entities/DbContractPersonnelReplacement.cs +++ /dev/null @@ -1,45 +0,0 @@ -using System; -using System.ComponentModel.DataAnnotations; -using Microsoft.EntityFrameworkCore; - -namespace Fusion.Resources.Database.Entities -{ - public class DbContractPersonnelReplacement - { - public Guid Id { get; set; } - - public Guid ProjectId { get; set; } - public Guid ContractId { get; set; } - public string Message { get; set; } = null!; - - [MaxLength(50)] - public string? ChangeType { get; set; } - [MaxLength(200)] - public string? UPN { get; set; } - [MaxLength(200)] - public string? FromPerson { get; set; } - [MaxLength(200)] - public string? ToPerson { get; set; } - - public DateTimeOffset Created { get; set; } - [MaxLength(200)] - public string? CreatedBy { get; set; } - - public static void OnModelCreating(ModelBuilder modelBuilder) - { - modelBuilder.Entity(x => - { - x.HasIndex(e => new { e.ProjectId, e.ContractId }).IsClustered(false) - .IncludeProperties(e => new - { - e.UPN, - e.FromPerson, - e.ToPerson, - e.ChangeType, - ReplacedTimestamp = e.Created, - ReplacedBy = e.CreatedBy - }); - }); - } - } -} \ No newline at end of file diff --git a/src/backend/api/Fusion.Resources.Database/Entities/DbContractorRequest.cs b/src/backend/api/Fusion.Resources.Database/Entities/DbContractorRequest.cs deleted file mode 100644 index 020d62898..000000000 --- a/src/backend/api/Fusion.Resources.Database/Entities/DbContractorRequest.cs +++ /dev/null @@ -1,99 +0,0 @@ -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using System; - -namespace Fusion.Resources.Database.Entities -{ - public class DbContractorRequest - { - public Guid Id { get; set; } - public string? Description { get; set; } - - - public DbContract Contract { get; set; } = null!; - public Guid ContractId { get; set; } - - public DbProject Project { get; set; } = null!; - public Guid ProjectId { get; set; } - - public DbContractPersonnel Person { get; set; } = null!; - public Guid PersonId { get; set; } - - public RequestPosition Position { get; set; } = new RequestPosition(); - - public DbRequestState State { get; set; } - public DbRequestCategory Category { get; set; } - - public Guid? OriginalPositionId { get; set; } - - public ProvisionStatus ProvisioningStatus { get; set; } = new ProvisionStatus(); - - public DateTimeOffset Created { get; set; } - public DateTimeOffset? Updated { get; set; } - public DbPerson CreatedBy { get; set; } = null!; - public DbPerson? UpdatedBy { get; set; } - - public Guid CreatedById { get; set; } - public Guid? UpdatedById { get; set; } - - public DateTimeOffset LastActivity { get; set; } - - internal static void OnModelCreating(ModelBuilder modelBuilder) - { - modelBuilder.Entity(entity => - { - entity.HasOne(e => e.Contract).WithMany().OnDelete(DeleteBehavior.Restrict); - entity.HasOne(e => e.Project).WithMany().OnDelete(DeleteBehavior.Restrict); - - entity.HasOne(e => e.CreatedBy).WithMany().OnDelete(DeleteBehavior.Restrict); - entity.HasOne(e => e.UpdatedBy).WithMany().OnDelete(DeleteBehavior.Restrict); - - - entity.OwnsOne(e => e.ProvisioningStatus, op => - { - op.Property(ps => ps.State).HasConversion(new EnumToStringConverter()); - }); - entity.OwnsOne(e => e.Position, op => - { - op.OwnsOne(p => p.TaskOwner); - }); - - entity.Property(e => e.State).HasConversion(new EnumToStringConverter()); - entity.Property(e => e.Category).HasConversion(new EnumToStringConverter()); - entity.Property(e => e.LastActivity).HasDefaultValue(DateTimeOffset.MinValue); - entity.HasIndex(e => e.LastActivity).IsClustered(false); - }); - } - - public class RequestPosition - { - public string Name { get; set; } = null!; - public Guid BasePositionId { get; set; } - public DateTime AppliesFrom { get; set; } - public DateTime AppliesTo { get; set; } - public string? Obs { get; set; } - public double Workload { get; set; } - - public PositionTaskOwner TaskOwner { get; set; } = new PositionTaskOwner(); - } - - public class PositionTaskOwner - { - public Guid? PositionId { get; set; } - public Guid? RequestId { get; set; } - } - - public class ProvisionStatus - { - public DbProvisionState State { get; set; } = DbProvisionState.NotProvisioned; - public Guid? PositionId { get; set; } - public DateTimeOffset? Provisioned { get; set; } - public string? ErrorMessage { get; set; } - public string? ErrorPayload { get; set; } - } - - public enum DbProvisionState { NotProvisioned, Provisioned, Error } - } - - -} diff --git a/src/backend/api/Fusion.Resources.Database/Entities/DbDelegatedRole.cs b/src/backend/api/Fusion.Resources.Database/Entities/DbDelegatedRole.cs deleted file mode 100644 index 4a3e3d6d6..000000000 --- a/src/backend/api/Fusion.Resources.Database/Entities/DbDelegatedRole.cs +++ /dev/null @@ -1,47 +0,0 @@ -using Microsoft.EntityFrameworkCore; -using System; - -namespace Fusion.Resources.Database.Entities -{ - public class DbDelegatedRole - { - public Guid Id { get; set; } - - public Guid PersonId { get; set; } - public DbPerson Person { get; set; } = null!; - - public DbDelegatedRoleType Type { get; set; } - public DbDelegatedRoleClassification Classification { get; set; } - - public DateTimeOffset Created { get; set; } - public DateTimeOffset ValidTo { get; set; } - public DateTimeOffset? RecertifiedDate { get; set; } - - public Guid CreatedById { get; set; } - public DbPerson CreatedBy { get; set; } = null!; - - public Guid? RecertifiedById { get; set; } - public DbPerson? RecertifiedBy { get; set; } = null!; - - public DbContract Contract { get; set; } = null!; - public Guid ContractId { get; set; } - - public DbProject Project { get; set; } = null!; - public Guid ProjectId { get; set; } - - internal static void OnModelCreating(ModelBuilder modelBuilder) - { - modelBuilder.Entity(entity => - { - entity.HasOne(e => e.Contract).WithMany().OnDelete(DeleteBehavior.Restrict); - entity.HasOne(e => e.Project).WithMany().OnDelete(DeleteBehavior.Restrict); - - entity.HasOne(e => e.Person).WithMany().OnDelete(DeleteBehavior.Restrict); - entity.HasOne(e => e.CreatedBy).WithMany().OnDelete(DeleteBehavior.Restrict); - entity.HasOne(e => e.RecertifiedBy).WithMany().OnDelete(DeleteBehavior.Restrict); - }); - - } - } - -} \ No newline at end of file diff --git a/src/backend/api/Fusion.Resources.Database/Entities/DbExternalPersonnelPerson.cs b/src/backend/api/Fusion.Resources.Database/Entities/DbExternalPersonnelPerson.cs deleted file mode 100644 index 5f778c875..000000000 --- a/src/backend/api/Fusion.Resources.Database/Entities/DbExternalPersonnelPerson.cs +++ /dev/null @@ -1,66 +0,0 @@ -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using System; -using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; - -namespace Fusion.Resources.Database.Entities -{ - - public class DbExternalPersonnelPerson - { - public Guid Id { get; set; } - - public Guid? AzureUniqueId { get; set; } - - [MaxLength(200)] - public string? UPN { get; set; } - - public DbAzureAccountStatus AccountStatus { get; set; } - - [MaxLength(100)] - public string Name { get; set; } = null!; - [MaxLength(50)] - public string FirstName { get; set; } = null!; - [MaxLength(50)] - public string LastName { get; set; } = null!; - - [MaxLength(100)] - public string Mail { get; set; } = null!; - [MaxLength(30)] - public string Phone { get; set; } = null!; - [MaxLength(100)] - public string? JobTitle { get; set; } - - [MaxLength(100)] - public string? PreferredContractMail { get; set; } - - [MaxLength(20)] - public string? DawinciCode { get; set; } - [MaxLength(100)] - public string? LinkedInProfile { get; set; } - - public bool? IsDeleted { get; set; } - public DateTimeOffset? Deleted { get; set; } - public ICollection Disciplines { get; set; } = null!; - - /// - /// This property is used for historic person identifiers. - /// Persons may be replaced multiple times, and can contain multiple personIds separated by comma - /// - public string? PersonIdReplacements { get; set; } - - internal static void OnModelCreating(ModelBuilder modelBuilder) - { - modelBuilder.Entity(entity => - { - entity.Property(e => e.AccountStatus).HasConversion(new EnumToStringConverter()); - - entity.HasMany(e => e.Disciplines).WithOne().OnDelete(DeleteBehavior.Cascade); - entity.HasIndex(e => e.Mail).IsClustered(false); - }); - - } - } - -} diff --git a/src/backend/api/Fusion.Resources.Database/Entities/DbProject.cs b/src/backend/api/Fusion.Resources.Database/Entities/DbProject.cs index 6874eed3b..7a45341a5 100644 --- a/src/backend/api/Fusion.Resources.Database/Entities/DbProject.cs +++ b/src/backend/api/Fusion.Resources.Database/Entities/DbProject.cs @@ -10,7 +10,6 @@ public class DbProject public string? DomainId { get; set; } public Guid OrgProjectId { get; set; } public string? State { get; set; } - public ICollection Contracts { get; set; } = null!; } diff --git a/src/backend/api/Fusion.Resources.Database/ResourcesDbContext.cs b/src/backend/api/Fusion.Resources.Database/ResourcesDbContext.cs index 190f3a182..9249601c1 100644 --- a/src/backend/api/Fusion.Resources.Database/ResourcesDbContext.cs +++ b/src/backend/api/Fusion.Resources.Database/ResourcesDbContext.cs @@ -22,7 +22,6 @@ public ResourcesDbContext(DbContextOptions options, ISqlAuth } public DbSet Persons { get; set; } - public DbSet Contracts { get; set; } public DbSet Projects { get; set; } public DbSet RequestComments { get; set; } public DbSet ResourceAllocationRequests { get; set; } @@ -38,16 +37,6 @@ public ResourcesDbContext(DbContextOptions options, ISqlAuth public DbSet DelegatedDepartmentResponsibles { get; set; } public DbSet DelegatedDepartmentResponsiblesHistory { get; set; } - - #region Moved to Contract Personnel. Only here for historical reasons - public DbSet ContractPersonnelReplacementChanges { get; set; } - public DbSet ContractPersonnel { get; set; } - public DbSet ContractorRequests { get; set; } - public DbSet ExternalPersonnel { get; set; } - public DbSet DelegatedRoles { get; set; } - #endregion - - protected override void OnModelCreating(ModelBuilder modelBuilder) { DbWorkflow.OnModelCreating(modelBuilder); @@ -60,19 +49,12 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) DbResourceAllocationRequest.OnModelCreating(modelBuilder); DbRequestAction.OnModelCreating(modelBuilder); DbConversationMessage.OnModelCreating(modelBuilder); - DbContractPersonnelReplacement.OnModelCreating(modelBuilder); DbSharedRequest.OnModelCreating(modelBuilder); DbSecondOpinionPrompt.OnModelCreating(modelBuilder); DbSecondOpinionResponse.OnModelCreating(modelBuilder); - #region Moved to Contract Personnel. Only here for historical reasons - DbContractPersonnel.OnModelCreating(modelBuilder); - DbContractorRequest.OnModelCreating(modelBuilder); - DbExternalPersonnelPerson.OnModelCreating(modelBuilder); - DbDelegatedRole.OnModelCreating(modelBuilder); DbDelegatedDepartmentResponsible.OnModelCreating(modelBuilder); DbDelegatedDepartmentResponsibleHistory.OnModelCreating(modelBuilder); - #endregion } protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)