2026-12-02 13:50:01 +01:00
|
|
|
|
using Helpdesk.Web.Api;
|
|
|
|
|
|
|
|
|
|
|
|
namespace Helpdesk.Web.Models;
|
|
|
|
|
|
|
|
|
|
|
|
public sealed class IssueListViewModel
|
|
|
|
|
|
{
|
|
|
|
|
|
/// <summary>Stavy závady v pořadí životního cyklu (kap. 6 návrhu) pro filtr.</summary>
|
|
|
|
|
|
public static readonly IReadOnlyList<string> Statuses =
|
|
|
|
|
|
["RECEIVED", "ASSIGNED", "IN_PROGRESS", "PENDING_VERIFICATION", "RESOLVED", "REJECTED"];
|
|
|
|
|
|
|
|
|
|
|
|
public required PagedResult<IssueSummary> Issues { get; init; }
|
|
|
|
|
|
public required IReadOnlyDictionary<int, string> CategoryNames { get; init; }
|
|
|
|
|
|
public required IReadOnlyDictionary<int, string> BuildingNames { get; init; }
|
|
|
|
|
|
public string? Status { get; init; }
|
|
|
|
|
|
|
|
|
|
|
|
public string CategoryName(int id) => CategoryNames.GetValueOrDefault(id, "Neznámá kategorie");
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>Budova a upřesnění místa, např. „Budova B – učebna B-205“.</summary>
|
2026-12-03 00:14:53 +01:00
|
|
|
|
public string? Location(IssueSummary issue) =>
|
|
|
|
|
|
FormatLocation(issue.BuildingId is { } id ? BuildingNames.GetValueOrDefault(id) : null, issue.LocationDetail);
|
|
|
|
|
|
|
|
|
|
|
|
public static string? FormatLocation(string? building, string? locationDetail)
|
2026-12-02 13:50:01 +01:00
|
|
|
|
{
|
2026-12-03 00:14:53 +01:00
|
|
|
|
return (building, locationDetail) switch
|
2026-12-02 13:50:01 +01:00
|
|
|
|
{
|
|
|
|
|
|
(null, null or "") => null,
|
|
|
|
|
|
(null, var detail) => detail,
|
|
|
|
|
|
(var b, null or "") => b,
|
|
|
|
|
|
var (b, detail) => $"{b} – {detail}",
|
|
|
|
|
|
};
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|