public void CalculateStudentPercentages(StudentSummary summary)
        {
            double maxTotal = summary.MaxTotal;
            double maxCount = summary.MaxCount;

            foreach (RatingQuery total in summary.RatingsList)
            {
                total.CPercentage = 100 * (total.CScore ?? 0)/ maxTotal;
                total.SPercentage = 100 * (total.SScore ?? 0)/ maxTotal;
                total.PPercentage = 100 * (total.PScore ?? 0)/ maxTotal;

                total.OnePercentage = 100 * total.OneCount / maxCount;
                total.TwoPercentage = 100 * total.TwoCount / maxCount;
                total.ThreePercentage = 100 * total.ThreeCount / maxCount;
            }
        }
        public StudentSummary getStudentTotals(int cohortID, int userID)
        {
            StudentSummary model = new StudentSummary()
            {
                RatingsList = db.Database.SqlQuery<RatingQuery>("facultyview @p0", new object[]{cohortID})
                .Where(ut=> ut.UserID == userID).ToList()
            };

            var CombinedTotals = model.RatingsList.Select(u => new { Total = (u.CScore ?? 0) + (u.PScore ?? 0) + (u.SScore ?? 0) });
            var CombinedCounts = model.RatingsList.Select(u => new { Count = u.OneCount + u.TwoCount + u.ThreeCount });

            model.MaxTotal = CombinedTotals.Any() ? (CombinedTotals.Max(t => t.Total)) : 0;
            model.MaxCount = CombinedCounts.Any() ? CombinedCounts.Max(c => c.Count) : 0;

            return model;
        }