private void writeRetroAverages(Average average) { NumberFormatInfo nfi = new CultureInfo("en-US", false).NumberFormat; //used for converting double to % if (average != null) { retroOverallAvgRateTB.Text = average.overallAvgRate.ToString("0.##"); retroCorbinAvgRateTB.Text = average.corbinAvgRate.ToString("0.##"); retroAllenAvgRateTB.Text = average.allenAvgRate.ToString("0.##"); retroOverallRecoTB.Text = average.overallRecommendPerc.ToString("P", nfi); retroCorbinAvgRecoTB.Text = average.corbinRecommendPerc.ToString("P", nfi); retroAllenAvgRecoTB.Text = average.allenRecommendPerc.ToString("P", nfi); } }
private Average calcAverages() { List <Retrospective> selItems = retroCLB.CheckedItems.Cast <Retrospective>().ToList(); if (selItems.Count > 0) { Average average = new Average(); List <int> overallRatings = new List <int>(); List <int> corbinsRatings = new List <int>(); List <int> allensRatings = new List <int>(); List <bool> overallRecommends = new List <bool>(); List <bool> corbinsRecommends = new List <bool>(); List <bool> allensRecommends = new List <bool>(); int tempRate = -2; //default state is 2 double overallAvgRate = 0.0; double corbinAvgRate = 0.0; double allenAvgRate = 0.0; double overallRecommendPerc = 0.0; double corbinRecommendPerc = 0.0; double allenRecommendPerc = 0.0; //TODO - finish making averages between selected retros foreach (Retrospective retro in selItems) { average = retro.average; if (retro.average != null) { overallRatings.AddRange(average.overallRatings); corbinsRatings.AddRange(average.corbinsRatings); allensRatings.AddRange(average.allensRatings); overallRecommends.AddRange(average.overallRecommends); corbinsRecommends.AddRange(average.corbinsRecommends); allensRecommends.AddRange(average.allensRecommends); } } if (overallRatings.Count > 0) { average = new Average(); //start fresh //calc score averages if (overallRatings.Count > 0) { overallAvgRate = Queryable.Average(overallRatings.ToArray().AsQueryable()); } if (corbinsRatings.Count > 0) { corbinAvgRate = Queryable.Average(corbinsRatings.ToArray().AsQueryable()); } if (allensRatings.Count > 0) { allenAvgRate = Queryable.Average(allensRatings.ToArray().AsQueryable()); } //calc recommend averages overallRecommendPerc = calcRecommendScore(overallRecommends); corbinRecommendPerc = calcRecommendScore(corbinsRecommends); allenRecommendPerc = calcRecommendScore(allensRecommends); average.overallRatings = overallRatings; average.corbinsRatings = corbinsRatings; average.allensRatings = allensRatings; average.overallRecommends = overallRecommends; average.corbinsRecommends = corbinsRecommends; average.allensRecommends = allensRecommends; average.overallAvgRate = overallAvgRate; average.corbinAvgRate = corbinAvgRate; average.allenAvgRate = allenAvgRate; average.overallRecommendPerc = overallRecommendPerc; average.corbinRecommendPerc = corbinRecommendPerc; average.allenRecommendPerc = allenRecommendPerc; return(average); } } return(null); }