Skip to content
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
2 changes: 2 additions & 0 deletions web/Areas/Personnel/Models/PhoneListUnit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ public class PhoneListUnit
public required int PhoneListId { get; set; }
public required string Name { get; set; }
public int? SortOrder { get; set; }
public string? ListProcName { get; set; }
public int? LegacyUnitId { get; set; }

public virtual PhoneList PhoneList { get; set; } = null!;
public virtual ICollection<PhoneListUnitPerson> PhoneListUnitPersons { get; set; } = [];
Expand Down
25 changes: 25 additions & 0 deletions web/Areas/Personnel/Models/VwUnitHeads.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
namespace Viper.Areas.Personnel.Models
{
/// <summary>
/// Read-only row from the phones.vwUnitHeads view: SVM units with their current
/// director and admin staff contacts. Replaces the legacy PhoneLists.dbo.vw_unitHeads,
/// keeping its column names, and adds Dean_Director_MothraID.
/// UnitId is the VIPER 2 SVMUnit id and does not match the legacy unitID.
/// </summary>
public class VwUnitHeads
{
public int UnitId { get; set; }
public string DeptCode { get; set; } = string.Empty;
public string UnitName { get; set; } = string.Empty;
public string Abbreviation { get; set; } = string.Empty;
public string? DirectorLocation { get; set; }
public string? DirectorName { get; set; }
public string? DirectorMailId { get; set; }
public string? DirectorMothraId { get; set; }
public string? DirectorPhone { get; set; }
public string? AdminName { get; set; }
public string? AdminMailId { get; set; }
public string? AdminMothraId { get; set; }
public string? AdminPhone { get; set; }
}
}
23 changes: 23 additions & 0 deletions web/Areas/Personnel/Models/VwVMDOPhoneList.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
namespace Viper.Areas.Personnel.Models
{
/// <summary>
/// Read-only row from the phones.vwVMDOPhoneList view: active, current-employee
/// members of the VMDO phone list with their phone numbers and office.
/// Replaces the legacy PhoneLists.dbo.vw_vmdoPhoneList, keeping its column names.
/// Adds LegacyUnitId for the VMDO Routing Slip page, and ListFirst so callers
/// can reproduce the view's sort order.
/// </summary>
public class VwVMDOPhoneList
{
public int UnitId { get; set; }
public string UnitName { get; set; } = string.Empty;
public string? MothraId { get; set; }
public bool ListFirst { get; set; }
public string LastName { get; set; } = string.Empty;
public string FirstName { get; set; } = string.Empty;
public string? PublicNumber { get; set; }
public string? PrivateNumber { get; set; }
public string? Office { get; set; }
public int? LegacyUnitId { get; set; }
}
}
48 changes: 48 additions & 0 deletions web/Areas/Personnel/PhonesDbContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ public PhonesDbContext(DbContextOptions<PhonesDbContext> options) : base(options
// Read-only cross-schema reference (users schema in same database)
public virtual DbSet<ViperPerson> ViperPerson { get; set; }

// Read-only views
public virtual DbSet<VwVMDOPhoneList> VwVMDOPhoneList { get; set; }
public virtual DbSet<VwUnitHeads> VwUnitHeads { get; set; }

protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
Expand Down Expand Up @@ -170,6 +174,8 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
entity.Property(e => e.Name).HasColumnName("Name").HasMaxLength(100);
entity.Property(e => e.PhoneListId).HasColumnName("PhoneListId");
entity.Property(e => e.SortOrder).HasColumnName("SortOrder");
entity.Property(e => e.ListProcName).HasColumnName("ListProcName").HasMaxLength(50).IsUnicode(false);
entity.Property(e => e.LegacyUnitId).HasColumnName("LegacyUnitId");

entity.HasOne(e => e.PhoneList)
.WithMany(s => s.PhoneListUnits)
Expand Down Expand Up @@ -216,5 +222,47 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
entity.Property(e => e.MailId);
entity.Property(e => e.CurrentEmployee);
});

// VwVMDOPhoneList (phones.vwVMDOPhoneList) - read-only view.
// Keyless: DISTINCT removes duplicate users.Person matches in practice,
// but the view doesn't guarantee unique rows.
modelBuilder.Entity<VwVMDOPhoneList>(entity =>
{
entity.HasNoKey();
entity.ToView("vwVMDOPhoneList", schema: "phones");

entity.Property(e => e.UnitId).HasColumnName("unitID");
entity.Property(e => e.UnitName).HasColumnName("unitName").HasMaxLength(100);
entity.Property(e => e.MothraId).HasColumnName("mothraID").HasMaxLength(8).IsUnicode(false);
entity.Property(e => e.ListFirst).HasColumnName("ListFirst");
entity.Property(e => e.LastName).HasColumnName("lastName").HasMaxLength(60);
entity.Property(e => e.FirstName).HasColumnName("firstName").HasMaxLength(30);
entity.Property(e => e.PublicNumber).HasColumnName("publicNumber").HasMaxLength(25);
entity.Property(e => e.PrivateNumber).HasColumnName("privateNumber").HasMaxLength(25);
entity.Property(e => e.Office).HasColumnName("office").HasMaxLength(100);
entity.Property(e => e.LegacyUnitId).HasColumnName("LegacyUnitId");
});

// VwUnitHeads (phones.vwUnitHeads) - read-only view.
// Keyless: units with several directors or admin staff return one row per pairing.
modelBuilder.Entity<VwUnitHeads>(entity =>
{
entity.HasNoKey();
entity.ToView("vwUnitHeads", schema: "phones");

entity.Property(e => e.UnitId).HasColumnName("unitID");
entity.Property(e => e.DeptCode).HasColumnName("dvtUnit_deptCode").HasMaxLength(6).IsUnicode(false);
entity.Property(e => e.UnitName).HasColumnName("dvtUnit_unitName").HasMaxLength(100);
entity.Property(e => e.Abbreviation).HasColumnName("dvtUnit_abbreviation").HasMaxLength(20);
entity.Property(e => e.DirectorLocation).HasColumnName("Location").HasMaxLength(50);
entity.Property(e => e.DirectorName).HasColumnName("Dean_Director").HasMaxLength(91);
entity.Property(e => e.DirectorMailId).HasColumnName("Dean_Director_MailID");
entity.Property(e => e.DirectorMothraId).HasColumnName("Dean_Director_MothraID").HasMaxLength(8).IsUnicode(false);
entity.Property(e => e.DirectorPhone).HasColumnName("Dir_Phone").HasMaxLength(25);
entity.Property(e => e.AdminName).HasColumnName("Admin_Staff").HasMaxLength(91);
entity.Property(e => e.AdminMailId).HasColumnName("Admin_Email");
entity.Property(e => e.AdminMothraId).HasColumnName("Admin_MothraID").HasMaxLength(8).IsUnicode(false);
entity.Property(e => e.AdminPhone).HasColumnName("Phone").HasMaxLength(25);
});
}
}
Loading