mirror of
https://github.com/Sea-Haven-Industries/shoc-backend.git
synced 2026-09-30 14:13:12 +00:00
Introduces DispatchUpliftRequest entity and tier-gated approval flow: vendors request a new NTE from the portal, dispatchers approve or deny in SHOC, and requests above a configurable threshold require a higher role. Adds DispatchController for PO-centric list/detail used by the new Vendor POs page. Seeds Dispatcher and Manager roles.
108 lines
4.6 KiB
C#
108 lines
4.6 KiB
C#
|
|
using Microsoft.AspNetCore.Identity;
|
|
using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel.DataAnnotations;
|
|
using System.ComponentModel.DataAnnotations.Schema;
|
|
using System.Data;
|
|
using System.Linq;
|
|
|
|
namespace Data.SeaHavenIndustries
|
|
{
|
|
public class ApplicationDbContext : IdentityDbContext<ApplicationUser>
|
|
{
|
|
public ApplicationDbContext(DbContextOptions<ApplicationDbContext> options) : base(options)
|
|
{
|
|
}
|
|
protected override void OnModelCreating(ModelBuilder builder)
|
|
{
|
|
base.OnModelCreating(builder);
|
|
foreach (var foreignKey in builder.Model.GetEntityTypes().SelectMany
|
|
(e => e.GetForeignKeys()))
|
|
{
|
|
foreignKey.DeleteBehavior = DeleteBehavior.Restrict;
|
|
}
|
|
|
|
builder.Entity<VendorAccessToken>()
|
|
.HasIndex(t => t.Token)
|
|
.IsUnique();
|
|
|
|
builder.Entity<DispatchUpliftRequest>()
|
|
.HasIndex(u => new { u.DispatchId, u.Status })
|
|
.IsUnique()
|
|
.HasFilter("[Status] = 'Pending'");
|
|
}
|
|
public DbSet<Category> Categories { get; set; }
|
|
public DbSet<Locations> Locations { get; set; }
|
|
public DbSet<Contacts> Contacts { get; set; }
|
|
public DbSet<WorkOrder> workOrders { get; set; }
|
|
public DbSet<Template> Templates { get; set; }
|
|
public DbSet<Comments> Comments { get; set; }
|
|
public DbSet<Quotes> Quotes { get; set; }
|
|
public DbSet<QuotesLineItems> QuotesLines { get; set; }
|
|
public DbSet<ForgetPasswordCode> ForgetPasswordCodes { get; set; }
|
|
public DbSet<WorkOrderContacts> WorkOrderContacts { get; set; }
|
|
public DbSet<WorkOrderCategories> workOrderCategories { get; set; }
|
|
public DbSet<WorkOrderAttachments> workOrderAttachments { get; set; }
|
|
public DbSet<WorkOrderAuditLog> WorkOrderAuditLogs { get; set; }
|
|
public DbSet<DropdownOption> DropdownOptions { get; set; }
|
|
public DbSet<Vendor> Vendors { get; set; }
|
|
public DbSet<VendorAccessToken> VendorAccessTokens { get; set; }
|
|
public DbSet<Dispatch> Dispatches { get; set; }
|
|
public DbSet<DispatchWorkOrder> DispatchWorkOrders { get; set; }
|
|
public DbSet<DispatchChecklistItem> DispatchChecklistItems { get; set; }
|
|
public DbSet<DispatchSignoff> DispatchSignoffs { get; set; }
|
|
public DbSet<DispatchUpliftRequest> DispatchUpliftRequests { get; set; }
|
|
public DbSet<TaskListTemplate> TaskListTemplates { get; set; }
|
|
public DbSet<TaskListTemplateItem> TaskListTemplateItems { get; set; }
|
|
|
|
// New DbSets for added entities
|
|
public DbSet<Accounts> Accounts { get; set; }
|
|
public DbSet<Addresses> Addresses { get; set; }
|
|
public DbSet<Assets> Assets { get; set; }
|
|
public DbSet<Employee> Employees { get; set; }
|
|
public DbSet<FollowUps> FollowUps { get; set; }
|
|
public DbSet<PMSchedules> PMSchedules { get; set; }
|
|
public DbSet<ContactDetails> ContactDetails { get; set; }
|
|
|
|
// Employee related DbSets
|
|
public DbSet<EmployeeAddress> EmployeeAddresses { get; set; }
|
|
public DbSet<EmployeePhone> EmployeePhones { get; set; }
|
|
public DbSet<EmployeeEmail> EmployeeEmails { get; set; }
|
|
public DbSet<Department> Departments { get; set; }
|
|
public DbSet<JobTitle> JobTitles { get; set; }
|
|
public DbSet<Region> Regions { get; set; }
|
|
|
|
}
|
|
public class ApplicationUser : IdentityUser
|
|
{
|
|
public string? FirstName { get; set; }
|
|
public string? LastName { get; set; }
|
|
public string? UniqueName { get; set; }
|
|
public string? Locations { get; set; }
|
|
public string? Contact { get; set; }
|
|
public DateTime? CreatedDate { get; set; }
|
|
public DateTime? DeletedDate { get; set; }
|
|
public bool? IsDeleted { get; set; }
|
|
public string? UserImage { get; set; }
|
|
public int? Type { get; set; } // 1 for users 0 for admin
|
|
public ICollection<Template>? Templates { get; set; }
|
|
public ICollection<WorkOrder>? WorkOrders { get; set; }
|
|
}
|
|
public class FullAuditEntity
|
|
{
|
|
[Key]
|
|
public int Id { get; set; }
|
|
public bool? IsDeleted { get; set; }
|
|
public string? createdby { get; set; }
|
|
public string? DeleterUserId { get; set; }
|
|
public DateTime? DeletionTime { get; set; }
|
|
public DateTime? CreatedDate { get; set; }
|
|
public DateTime? LastModificationTime { get; set; }
|
|
public int? LastModifierUserId { get; set; }
|
|
|
|
}
|
|
|
|
}
|