@model IEnumerable @{ ViewData["Title"] = "Customers"; var searchTerm = ViewData["SearchTerm"] as string ?? ""; }

Customer Management

Manage customer accounts, view order history, and monitor risk scores

@if (!string.IsNullOrEmpty(searchTerm)) { Clear }
@Model.Count() customer@(Model.Count() != 1 ? "s" : "") found
Total Customers

@Model.Count()

Active

@Model.Count(c => c.IsActive && !c.IsBlocked)

Blocked

@Model.Count(c => c.IsBlocked)

High Risk (>70)

@Model.Count(c => c.RiskScore > 70)

@if (Model.Any()) {
Customer List
@foreach (var customer in Model) { }
Customer Telegram Status Orders Total Spent Risk Score Last Active Actions
@customer.TelegramDisplayName @if (!string.IsNullOrEmpty(customer.TelegramFirstName) && !string.IsNullOrEmpty(customer.TelegramLastName)) {
@customer.TelegramFirstName @customer.TelegramLastName }
@@@customer.TelegramUsername
ID: @customer.TelegramUserId
@if (customer.IsBlocked) { Blocked } else if (!customer.IsActive) { Deleted } else { Active }
@customer.TotalOrders @if (customer.SuccessfulOrders > 0) {
@customer.SuccessfulOrders successful } @if (customer.CancelledOrders > 0) {
@customer.CancelledOrders cancelled } @if (customer.DisputedOrders > 0) {
@customer.DisputedOrders disputed }
£@customer.TotalSpent.ToString("N2") @if (customer.AverageOrderValue > 0) {
Avg: £@customer.AverageOrderValue.ToString("N2") }
@{ var riskBadgeClass = customer.RiskScore >= 80 ? "bg-danger" : customer.RiskScore >= 50 ? "bg-warning" : customer.RiskScore >= 30 ? "bg-info" : "bg-success"; var riskIcon = customer.RiskScore >= 80 ? "fa-exclamation-triangle" : customer.RiskScore >= 50 ? "fa-exclamation-circle" : customer.RiskScore >= 30 ? "fa-info-circle" : "fa-check-circle"; } @customer.RiskScore @if (customer.LastActiveAt > DateTime.MinValue) { var daysAgo = (DateTime.UtcNow - customer.LastActiveAt).Days; @customer.LastActiveAt.ToString("MMM dd, yyyy") @if (daysAgo <= 1) {
Today } else if (daysAgo <= 7) {
@daysAgo days ago } else if (daysAgo <= 30) {
@daysAgo days ago } else {
@daysAgo days ago } } else { Never }
} else {
@if (!string.IsNullOrEmpty(searchTerm)) { No customers found matching "@searchTerm"

Try a different search term or view all customers.

} else { No customers yet

Customers will appear here automatically when they place their first order through the TeleBot.

}
}