Initial commit
This commit is contained in:
@@ -0,0 +1,93 @@
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using PowderCoating.Core.Enums;
|
||||
using System.Linq;
|
||||
|
||||
namespace PowderCoating.Core.Entities;
|
||||
|
||||
public class ApplicationUser : IdentityUser
|
||||
{
|
||||
// Multi-tenancy
|
||||
public int CompanyId { get; set; }
|
||||
public virtual Company? Company { get; set; } // Nullable to avoid EF query filter issues
|
||||
public string? CompanyRole { get; set; } // CompanyAdmin, Manager, Worker, Viewer
|
||||
|
||||
// Basic Information
|
||||
public string FirstName { get; set; } = string.Empty;
|
||||
public string LastName { get; set; } = string.Empty;
|
||||
public string? EmployeeNumber { get; set; }
|
||||
|
||||
public DateTime HireDate { get; set; }
|
||||
public DateTime? TerminationDate { get; set; }
|
||||
|
||||
public string? Address { get; set; }
|
||||
public string? City { get; set; }
|
||||
public string? State { get; set; }
|
||||
public string? ZipCode { get; set; }
|
||||
|
||||
public string? Department { get; set; }
|
||||
public string? Position { get; set; }
|
||||
|
||||
// User Preferences
|
||||
public string? Theme { get; set; } = "light";
|
||||
public string? DateFormat { get; set; } = "MM/dd/yyyy";
|
||||
public string? TimeZone { get; set; } = "America/New_York";
|
||||
public int? DashboardLayout { get; set; }
|
||||
|
||||
// Settings
|
||||
public bool IsActive { get; set; } = true;
|
||||
public bool CanViewShopFloor { get; set; } = true;
|
||||
public bool CanManageJobs { get; set; } = false;
|
||||
public bool CanManageInventory { get; set; } = false;
|
||||
public bool CanManageCustomers { get; set; } = false;
|
||||
public bool CanCreateQuotes { get; set; } = false;
|
||||
public bool CanApproveQuotes { get; set; } = false;
|
||||
public bool CanManageCalendar { get; set; } = false;
|
||||
public bool CanViewCalendar { get; set; } = true;
|
||||
public bool CanManageProducts { get; set; } = false;
|
||||
public bool CanViewProducts { get; set; } = true;
|
||||
public bool CanManageEquipment { get; set; } = false;
|
||||
public bool CanManageVendors { get; set; } = false;
|
||||
public bool CanManageMaintenance { get; set; } = false;
|
||||
public bool CanManageInvoices { get; set; } = false;
|
||||
public bool CanViewReports { get; set; } = false;
|
||||
|
||||
// Profile Photo (filesystem storage)
|
||||
public string? ProfilePictureFilePath { get; set; } // Relative path from ContentRoot/media/ (e.g., "123/profile-photos/user-abc.jpg")
|
||||
|
||||
public string? SidebarColor { get; set; } = "ocean";
|
||||
public string? Notes { get; set; }
|
||||
|
||||
public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
|
||||
public DateTime? UpdatedAt { get; set; }
|
||||
public DateTime? LastLoginDate { get; set; }
|
||||
|
||||
// Ban
|
||||
public bool IsBanned { get; set; } = false;
|
||||
public DateTime? BannedAt { get; set; }
|
||||
public string? BanReason { get; set; }
|
||||
public string? BannedByUserId { get; set; }
|
||||
|
||||
// Relationships
|
||||
public virtual ICollection<Quote> PreparedQuotes { get; set; } = new List<Quote>();
|
||||
public virtual ICollection<MaintenanceRecord> PerformedMaintenances { get; set; } = new List<MaintenanceRecord>();
|
||||
|
||||
// Full name helper
|
||||
public string FullName => $"{FirstName} {LastName}";
|
||||
|
||||
/// <summary>
|
||||
/// Sets every <c>Can*</c> boolean permission property to <c>true</c>.
|
||||
/// Use this when creating a first-time company admin so that any permission added
|
||||
/// to this class in the future is automatically granted without needing to update
|
||||
/// every account-creation path individually.
|
||||
/// </summary>
|
||||
public void GrantAllPermissions()
|
||||
{
|
||||
foreach (var prop in typeof(ApplicationUser).GetProperties()
|
||||
.Where(p => p.Name.StartsWith("Can") &&
|
||||
p.PropertyType == typeof(bool) &&
|
||||
p.CanWrite))
|
||||
{
|
||||
prop.SetValue(this, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user