Exemplo n.º 1
0
        public SurveySummary GetSurveySummary()
        {
            var submittedSurveys = surveyRepository.GetSubmittedSurveys();
            var surveySummary    = new SurveySummary
            {
                TotalNumberOfAnswers = submittedSurveys.Count(),

                //AMS -> NZF
                //BG  -> OT
                //IA  -> VN
                //KI  -> XV
                //LV  -> YI
                //NS  -> AF
                //ZR  -> ME
                TotalsPerDcs = new List <NumbersPerDc>
                {
                    new NumbersPerDc
                    {
                        DeliveryCenterName     = "Iasi",
                        TotalNumberOfAnswers   = submittedSurveys.Count(ss => ss.UID.StartsWith("VN")),
                        TotalNumberOfEmployees = "114"
                    },
                    new NumbersPerDc
                    {
                        DeliveryCenterName     = "Belgrade",
                        TotalNumberOfAnswers   = submittedSurveys.Count(ss => ss.UID.StartsWith("OT")),
                        TotalNumberOfEmployees = "117"
                    },
                    new NumbersPerDc
                    {
                        DeliveryCenterName     = "Novi Sad",
                        TotalNumberOfAnswers   = submittedSurveys.Count(ss => ss.UID.StartsWith("AF")),
                        TotalNumberOfEmployees = "346"
                    },
                    new NumbersPerDc
                    {
                        DeliveryCenterName     = "Zrenjanin",
                        TotalNumberOfAnswers   = submittedSurveys.Count(ss => ss.UID.StartsWith("ME")),
                        TotalNumberOfEmployees = "38"
                    },
                    new NumbersPerDc
                    {
                        DeliveryCenterName     = "Kiev",
                        TotalNumberOfAnswers   = submittedSurveys.Count(ss => ss.UID.StartsWith("XV")),
                        TotalNumberOfEmployees = "209"
                    },
                    new NumbersPerDc
                    {
                        DeliveryCenterName     = "Lviv",
                        TotalNumberOfAnswers   = submittedSurveys.Count(ss => ss.UID.StartsWith("YI")),
                        TotalNumberOfEmployees = "43"
                    }
                }
            };

            return(surveySummary);
        }
Exemplo n.º 2
0
        public SurveySummary GetSurveySummary(string surveyName, int userId)
        {
            var request = new SurveyRequest()
            {
                SurveyName      = surveyName,
                IncludeResponse = true,
                UserID          = userId,
                CacheForUser    = true
            };

            var survey = GetSurvey(request);

            if (survey == null)
            {
                throw new Exception("Invalid Survey Name: " + surveyName);
            }

            var summary = new SurveySummary()
            {
                SurveyID     = survey.SurveyID,
                SurveyName   = survey.SurveyName,
                Score        = survey.Status.Score,
                State        = survey.Status.State,
                DisplayScore = survey.Status.DisplayScore
            };

            foreach (var page in survey.Pages.Where(p => !p.IsSummary))
            {
                var pageStatus           = survey.Status.Pages.First(p => p.Name == page.PageName);
                var pageScoreDescription = page.ScoreRanges.FirstOrDefault(d => pageStatus.Score >= d.MinScore && pageStatus.Score <= d.MaxScore);

                var pageSummary = new SurveyPageSummary()
                {
                    SurveyPageID = page.SurveyPageID,
                    PageName     = page.PageName,
                    Score        = pageStatus.Score,
                    DisplayScore = pageStatus.DisplayScore,
                    State        = pageStatus.State,
                    Tooltip      = page.Tooltip,
                    ScoreSummary = pageScoreDescription != null ? pageScoreDescription.Description : string.Empty
                };

                if (!page.SuggestedContents.IsNullOrEmpty())
                {
                    pageSummary.SuggestedContent = page.SuggestedContents.DistinctBy(a => a.Url).Select(s => new SurveySummaryContent()
                    {
                        Title = s.Title, Url = s.Url
                    }).ToList();
                }

                summary.Pages.Add(pageSummary);
            }

            return(summary);
        }