Skip to content

Commit

Permalink
Merge pull request #568 from DFE-Digital/feature/179914-assign-user-r…
Browse files Browse the repository at this point in the history
…ole-capabilitiies

Assign user with role capabilities
  • Loading branch information
mshakirdfe authored Sep 17, 2024
2 parents db6a150 + 64a3f65 commit 2493377
Show file tree
Hide file tree
Showing 36 changed files with 2,532 additions and 796 deletions.
18 changes: 1 addition & 17 deletions Dfe.Academies.Academisation.Data/AcademisationContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@
using Dfe.Academies.Academisation.Domain.ProjectAggregate;
using Dfe.Academies.Academisation.Domain.ProjectGroupsAggregate;
using Dfe.Academies.Academisation.Domain.SeedWork;
using Dfe.Academies.Academisation.Domain.TransferProjectAggregate;
using Dfe.Academies.Academisation.Domain.UserRoleAggregate;
using Dfe.Academies.Academisation.Domain.TransferProjectAggregate;
using MediatR;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.ChangeTracking;
Expand Down Expand Up @@ -55,7 +54,6 @@ public class AcademisationContext(DbContextOptions<AcademisationContext> options

public DbSet<TransferProject> TransferProjects { get; set; } = null!;
public DbSet<ProjectGroup> ProjectGroups { get; set; } = null!;
public DbSet<UserRole> UserRoles { get; set; } = null!;

public override int SaveChanges()
{
Expand Down Expand Up @@ -239,7 +237,6 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)

modelBuilder.Entity<FormAMatProject>(ConfigureFormAMatProject);
modelBuilder.Entity<ProjectGroup>(ConfigureProjectGroup);
modelBuilder.Entity<UserRole>(ConfigureUserRole);
modelBuilder.Entity<OpeningDateHistory>(ConfigureOpeningDateHistory);

// Replicatiing functionality to generate urn, this will have to be ofset as part of the migration when we go live
Expand All @@ -263,19 +260,6 @@ private void ConfigureProjectGroup(EntityTypeBuilder<ProjectGroup> builder)
});
}

private static void ConfigureUserRole(EntityTypeBuilder<UserRole> builder)
{
builder.ToTable("UserRoles", DEFAULT_SCHEMA);
builder.HasKey(e => e.Id);

builder.OwnsOne(a => a.AssignedUser, a =>
{
a.Property(p => p.Id).HasColumnName(Assigned_User_Id);
a.Property(p => p.EmailAddress).HasColumnName(Assigned_User_Email_Address);
a.Property(p => p.FullName).HasColumnName(Assigned_User_Full_Name);
});
}

private void ConfigureOpeningDateHistory(EntityTypeBuilder<OpeningDateHistory> builder)
{
builder.ToTable("OpeningDateHistories", DEFAULT_SCHEMA);
Expand Down
Loading

0 comments on commit 2493377

Please sign in to comment.