Пример #1
0
        public Dictionary <string, double> GetAgePctgListByTest(int test_id)
        {
            Dictionary <string, double> listedResults = new Dictionary <string, double>();
            var evaluations = new EvaluationsServices().GetByTest(test_id);
            IQueryable <IGrouping <int, Age> > groups = evaluations.Select(c => c.Age).OrderBy(p => p.Name).GroupBy(c => c.Id);

            foreach (var group in groups)
            {
                int    group_id   = group.Select(c => c.Id).FirstOrDefault();
                string group_name = group.Select(c => c.Name).FirstOrDefault();
                double pct        = evaluations.Where(c => c.Age_Id == group_id).Count();// *100 / evaluations.Count();
                listedResults.Add(group_name, pct);
            }
            return(listedResults);
        }
Пример #2
0
        private IQueryable <Evaluation> GetEvaluationsByUbication(int?test_id, int?country_id,
                                                                  int?state_id, int?region_id)
        {
            IQueryable <Evaluation> evaluations = new EvaluationsServices().GetByTest(test_id);

            if (country_id.HasValue)
            {
                if (state_id.HasValue)
                {
                    evaluations = evaluations.Where(l => l.Location.State_Id == state_id.Value);
                }
                else
                {
                    evaluations = evaluations.Where(l => l.Location.State.Country_Id == country_id.Value);
                }
            }
            else
            if (region_id.HasValue)
            {
                evaluations = evaluations.Where(l => l.Location.Region_Id == region_id.Value);
            }
            return(evaluations);
        }