Separate ticket overview capabilities from counts
This commit is contained in:
@@ -314,15 +314,23 @@ namespace C4IT.F4SD
|
||||
"ServiceRequestsCritical",
|
||||
"ServiceRequestsNewInfo",
|
||||
"UnassignedTickets",
|
||||
"UnassignedTicketsCritical",
|
||||
"TicketAndServiceRequestsEnabled"
|
||||
};
|
||||
|
||||
public class TicketOverviewCountsResult
|
||||
{
|
||||
[JsonProperty("counts")]
|
||||
public Dictionary<string, int> Counts { get; set; } = new Dictionary<string, int>(StringComparer.OrdinalIgnoreCase);
|
||||
}
|
||||
"UnassignedTicketsCritical"
|
||||
};
|
||||
|
||||
public class TicketOverviewCapabilities
|
||||
{
|
||||
[JsonProperty("ticketAndServiceRequestsEnabled")]
|
||||
public bool TicketAndServiceRequestsEnabled { get; set; } = true;
|
||||
}
|
||||
|
||||
public class TicketOverviewCountsResult
|
||||
{
|
||||
[JsonProperty("counts")]
|
||||
public Dictionary<string, int> Counts { get; set; } = new Dictionary<string, int>(StringComparer.OrdinalIgnoreCase);
|
||||
|
||||
[JsonProperty("capabilities")]
|
||||
public TicketOverviewCapabilities Capabilities { get; set; } = new TicketOverviewCapabilities();
|
||||
}
|
||||
|
||||
public class TicketOverviewCountsByRoleResult
|
||||
{
|
||||
@@ -409,7 +417,7 @@ namespace C4IT.F4SD
|
||||
}
|
||||
}
|
||||
|
||||
return new TicketOverviewCountsResult { Counts = counts };
|
||||
return CreateTicketOverviewCountsResult(counts);
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
@@ -985,12 +993,21 @@ namespace C4IT.F4SD
|
||||
|
||||
private static int CountTicketOverviewEntries(IEnumerable<TicketOverviewEntry> entries, string key)
|
||||
{
|
||||
if (string.Equals(key?.Trim(), "TicketAndServiceRequestsEnabled", StringComparison.OrdinalIgnoreCase))
|
||||
return ticketAndServiceRequestEnabled() ? 1 : 0;
|
||||
|
||||
return (entries ?? Enumerable.Empty<TicketOverviewEntry>())
|
||||
.Count(entry => MatchesTicketOverviewKey(entry, key));
|
||||
}
|
||||
|
||||
private static TicketOverviewCountsResult CreateTicketOverviewCountsResult(Dictionary<string, int> counts)
|
||||
{
|
||||
return new TicketOverviewCountsResult
|
||||
{
|
||||
Counts = counts ?? new Dictionary<string, int>(StringComparer.OrdinalIgnoreCase),
|
||||
Capabilities = new TicketOverviewCapabilities
|
||||
{
|
||||
TicketAndServiceRequestsEnabled = ticketAndServiceRequestEnabled()
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private static bool GetBoolValue(object value)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user