aktueller Stand
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace FasdCockpitCommunication.TicketOverview
|
||||
{
|
||||
internal sealed class TicketOverviewCountsResponse
|
||||
{
|
||||
[JsonProperty("counts")]
|
||||
public Dictionary<string, int> Counts { get; set; } = new Dictionary<string, int>(StringComparer.OrdinalIgnoreCase);
|
||||
|
||||
public Dictionary<string, int> ToDictionary(IEnumerable<string> expectedKeys)
|
||||
{
|
||||
var comparer = StringComparer.OrdinalIgnoreCase;
|
||||
var output = new Dictionary<string, int>(comparer);
|
||||
|
||||
if (expectedKeys != null)
|
||||
{
|
||||
foreach (var key in expectedKeys)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(key))
|
||||
continue;
|
||||
|
||||
if (Counts != null && Counts.TryGetValue(key, out var count))
|
||||
output[key] = count;
|
||||
else
|
||||
output[key] = 0;
|
||||
}
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
if (Counts != null)
|
||||
{
|
||||
foreach (var kvp in Counts)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(kvp.Key))
|
||||
continue;
|
||||
|
||||
output[kvp.Key] = kvp.Value;
|
||||
}
|
||||
}
|
||||
|
||||
return output;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user