Skip to content

Instantly share code, notes, and snippets.

@ornerymoose
Created July 12, 2019 20:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ornerymoose/a4902789f20fe69b3335683eb372d0b3 to your computer and use it in GitHub Desktop.
Save ornerymoose/a4902789f20fe69b3335683eb372d0b3 to your computer and use it in GitHub Desktop.
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