private TraineeshipApplicationMetrics GetTraineeshipApplicationMetrics()
        {
            var averageApplicationCountPerTraineeship = _traineeshipMetricsRepository.GetAverageApplicationCountPerTraineeship();
            var traineeshipApplicationMetrics         = new TraineeshipApplicationMetrics();

            if (averageApplicationCountPerTraineeship != null)
            {
                traineeshipApplicationMetrics.TraineeshipsWithApplicationsCount = averageApplicationCountPerTraineeship["traineeshipsWithApplicationsCount"].AsInt32;
                traineeshipApplicationMetrics.TotalApplicationsCount            = averageApplicationCountPerTraineeship["count"].AsInt32;
                traineeshipApplicationMetrics.AverageApplicationsPerTraineeship = averageApplicationCountPerTraineeship["average"].AsDouble;
            }
            ;

            var applicationCountPerTraineeship = _traineeshipMetricsRepository.GetApplicationCountPerTraineeship();

            foreach (var applicationCount in applicationCountPerTraineeship)
            {
                var vacancyId = applicationCount["_id"]["VacancyId"].AsInt32;
                var title     = applicationCount["_id"]["Title"].AsString;
                var count     = applicationCount["count"].AsInt32;

                var traineeshipMetrics = new TraineeshipMetrics
                {
                    Id               = vacancyId,
                    Title            = title,
                    ApplicationCount = count
                };

                traineeshipApplicationMetrics.TraineeshipMetrics[vacancyId] = traineeshipMetrics;
            }
            return(traineeshipApplicationMetrics);
        }
        private static void WriteTraineeshipApplicationMetricsCsv(TraineeshipApplicationMetrics userApplicationMetrics, DateTime fileDateTime)
        {
            var fileName   = string.Format("TraineeshipApplicationMetrics_{0}.csv", fileDateTime.ToString("s").Replace(":", "-"));
            var textWriter = new StreamWriter(fileName);
            var csv        = new CsvWriter(textWriter);

            csv.WriteRecords(userApplicationMetrics.TraineeshipMetrics.Values);
            textWriter.Flush();
            textWriter.Close();
        }