@using PowderCoating.Core.Enums @using PowderCoating.Web.Controllers @using Microsoft.AspNetCore.Html @model List @{ ViewData["Title"] = "Usage & Quota"; string BarColor(int used, int max) { if (max <= 0) return "bg-secondary"; double pct = (double)used / max; if (pct >= 1.0) return "bg-danger"; if (pct >= 0.8) return "bg-warning"; return "bg-success"; } string LimitDisplay(int max) => max == -1 ? "∞" : max == 0 ? "—" : max.ToString(); int BarWidth(int used, int max) { if (max <= 0) return 0; return Math.Min(100, (int)Math.Round((double)used / max * 100)); } } @section Styles { }

Usage & Quota

@* Summary cards *@
@ViewBag.TotalCount
Companies
@ViewBag.AtLimitCount
At or Over Limit
@ViewBag.NearLimitCount
Near Limit (≥80%)
@(Model.Count - (int)ViewBag.AtLimitCount - (int)ViewBag.NearLimitCount)
Healthy
@* Filters *@
Clear
@* Desktop table *@
@Model.Count company(ies)
@if (!Model.Any()) { } @foreach (var row in Model) { var rowClass = row.IsAtLimit ? "table-danger" : row.IsNearLimit ? "table-warning" : ""; }
Company Plan Status Users Active Jobs Customers Active Quotes Catalog
No companies found.
@row.CompanyName @if (row.IsComped) { Comped } @if (!row.IsActive) { Inactive } @row.PlanName @{ var sc = row.Status switch { SubscriptionStatus.Active => "success", SubscriptionStatus.GracePeriod => "warning", SubscriptionStatus.Expired => "danger", _ => "secondary" }; } @row.Status @UsageCell(row.Users, row.MaxUsers) @UsageCell(row.ActiveJobs, row.MaxActiveJobs) @UsageCell(row.Customers, row.MaxCustomers) @UsageCell(row.ActiveQuotes, row.MaxActiveQuotes) @UsageCell(row.CatalogItems, row.MaxCatalogItems) Manage
@* Mobile card view — shown on screens < 992px *@
@Model.Count company(ies)
@if (!Model.Any()) {
No companies found.
}
@foreach (var row in Model) { var alertIcon = row.IsAtLimit ? "bi-exclamation-circle text-danger" : row.IsNearLimit ? "bi-exclamation-triangle text-warning" : ""; var iconBg = row.IsAtLimit ? "bg-danger" : row.IsNearLimit ? "bg-warning" : "bg-primary"; var statusColor = row.Status switch { SubscriptionStatus.Active => "success", SubscriptionStatus.GracePeriod => "warning", SubscriptionStatus.Expired => "danger", _ => "secondary" };
@row.CompanyName @if (row.IsComped) { Comped } @if (!row.IsActive) { Inactive }
@row.PlanName — @row.Status
Users @row.Users / @LimitDisplay(row.MaxUsers)
Active Jobs @row.ActiveJobs / @LimitDisplay(row.MaxActiveJobs)
Customers @row.Customers / @LimitDisplay(row.MaxCustomers)
Active Quotes @row.ActiveQuotes / @LimitDisplay(row.MaxActiveQuotes)
Catalog Items @row.CatalogItems / @LimitDisplay(row.MaxCatalogItems)
}
@{ IHtmlContent UsageCell(int used, int max) { if (max == -1) { return new HtmlString($"{used} / ∞"); } if (max == 0) { return new HtmlString($"{used} / —"); } var pct = Math.Min(100, (int)Math.Round((double)used / max * 100)); var color = pct >= 100 ? "danger" : pct >= 80 ? "warning" : "success"; return new HtmlString($@"
{used}/{max}
"); } }