/// <summary>
        ///
        /// </summary>
        /// <param name="reportTemplate"></param>
        /// <param name="organizations"></param>
        /// <returns></returns>
        public static IEnumerable <ReportTemplateActivePeriodObjectValue> GetAllActivePeriods(this ReportTemplate reportTemplate, IEnumerable <Organization> organizations)
        {
            var periods = organizations.GetLastYear()
                          .ToDictionary(templateActivePeriod =>
                                        templateActivePeriod.Period,

                                        templateActivePeriod =>
                                        templateActivePeriod.PeriodStatuses
                                        .ToDictionary(periodStatus => periodStatus.Organization));

            var reportTemplateActivePeriods = reportTemplate.GetActivePeriods();

            foreach (var activePeriod in reportTemplateActivePeriods)
            {
                foreach (var periodStatus in activePeriod.PeriodStatuses)
                {
                    periods[activePeriod.Period][periodStatus.Organization] = periodStatus;
                }
            }

            return(periods.Select(keyValuePair =>
                                  new ReportTemplateActivePeriodObjectValue(
                                      period: keyValuePair.Key,
                                      periodStatuses: keyValuePair.Value.Values)));
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="reportTemplate"></param>
        /// <param name="organization"></param>
        /// <returns></returns>
        public static IEnumerable <CreationPeriodObjectValue> GetAllCreationPeriods(this ReportTemplate reportTemplate, Organization organization)
        {
            var periods = new List <Organization> {
                organization
            }.GetLastYear()
            .ToDictionary(key => key.Period);

            var reportTemplateActivePeriods = reportTemplate.GetActivePeriods()
                                              .Where(activePeriod => activePeriod.PeriodStatuses
                                                     .Any(periodStatus => periodStatus.Organization == organization.Id));

            foreach (var activePeriod in reportTemplateActivePeriods)
            {
                periods[activePeriod.Period] = activePeriod;
            }

            return(periods.Values
                   .Where(p =>
                          p.PeriodStatuses.Any(periodStatus =>
                                               periodStatus.IsActivePeriod == true && periodStatus.Organization == organization.Id))
                   .Select(p => new CreationPeriodObjectValue(p.Period)));
        }