Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
the below works but isn't very clean.
// initalize resi_vid/hsd/voice and comm_vid/hsd_voice to 0...
// result.summary.products is List<ImpactProduct> Summary.products
foreach (var r in result.summary.products)
{
if (r.customer_class == "Residential" && r.name == "Video")
{
resi_vid = r.customer_count;
}
if (r.customer_class == "Residential" && r.name == "HSD")
{
resi_hsd = r.customer_count;
}
if (r.customer_class == "Residential" && r.name == "Voice")
{
resi_voice = r.customer_count;
}
if (r.customer_class == "Commercial" && r.name == "SMB Video")
{
comm_vid = r.customer_count;
}
if (r.customer_class == "Commercial" && r.name == "SMB HSD")
{
comm_hsd = r.customer_count;
}
if (r.customer_class == "Commercial" && r.name == "SMB Voice")
{
comm_voice = r.customer_count;
}
}
var subscriberCounts = new SubscriberCountModel
{
Residential = {
Video = resi_vid,
Internet = resi_hsd,
Voice = resi_voice
},
Commercial = {
Video = comm_vid,
Internet = comm_hsd,
Voice = comm_voice
}
};
public class ImpactProduct
{
public string name { get; set; }
public string customer_class { get; set; }
public int customer_count { get; set; }
}
public class Summary
{
public List<ImpactProduct> products { get; set; }
}
public class RootObject
{
public Summary summary { get; set; }
}
"summary": {
"products": [
{
"name": "Video",
"customer_class": "Commercial",
"customer_count": 500,
},
{
"name": "HSD",
"customer_class": "Residential",
"customer_count": 1200,
},
{
"name": "Voice",
"customer_class": "Residential",
"customer_count": 1900,
}
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment