public static GuardianStatistics GetGuardianStatistics() { GuardianStatistics guardStats = new GuardianStatistics(); List <Guardian> guardList = new List <Guardian>(); try { // Replace with API code using (var context = new SMSContext()) { guardList = context.Guardians.ToList(); guardStats.TotalCount = guardList.Count(); } } catch (Exception eSql) { // Your code may benefit from more robust error handling or logging. // This logging is just a reminder that you should handle exceptions when connecting to remote data. System.Diagnostics.Debug.WriteLine($"Exception: {eSql.Message} {eSql.InnerException?.Message}"); } return(guardStats); }
private void DisplayNarrationStats() { SfChart chart = new SfChart() { Header = "Narration Statistics", FontSize = 18, Height = 300, Width = 500 }; GuardianStatistics GuardianStats = new GuardianStatistics(); NarrationStatistics NarrationStats = new NarrationStatistics(); NarrationStats = NarrationDataService.GetNarrationStatistics(); TotalNarrationCount = NarrationStats.TotalNarrationCount; ActiveSeries = new List <ActivePieModel>() { new ActivePieModel { Category = "Orphans", Value = NarrationStats.OrphanNarrationCount }, new ActivePieModel { Category = "Guardians", Value = NarrationStats.GuardianNarrationCount } }; //Adding Legends for the chart ChartLegend legend = new ChartLegend(); chart.Legend = legend; PieSeries series = new PieSeries() { ItemsSource = ActiveSeries, XBindingPath = "Category", YBindingPath = "Value", ShowTooltip = true, Label = "Values", AdornmentsInfo = new ChartAdornmentInfo() { ShowLabel = true }, }; chart.Series.Add(series); stackNarrationStats.Children.Add(chart); TextBlock txtTotal = new TextBlock(); txtTotal.FontSize = 14; txtTotal.HorizontalAlignment = Windows.UI.Xaml.HorizontalAlignment.Center; txtTotal.Text = "Total Narration Count: " + TotalNarrationCount.ToString(); stackNarrationStats.Children.Add(txtTotal); }