Esempio n. 1
0
        /// <summary>
        /// Budget total by year
        /// </summary>
        /// <param name="programId"></param>
        /// <returns></returns>
        public async Task <SnapshotGraphDTO> GetProgramBudgetByYear(int programId)
        {
            var childPrograms = programService.GetAllChildProgramsWithParent(programId);
            var dto           = await SnapshotQueries.CreateGetProgramBudgetByYearQuery(Context, childPrograms.Select(p => p.ProgramId).ToList());

            SnapshotGraphDTO graphValues = new SnapshotGraphDTO
            {
                key    = "Budget",
                values = dto.OrderBy(x => x.Key).ToList()
            };

            return(graphValues);
        }
Esempio n. 2
0
        /// <summary>
        /// Count of participants by year for graph
        /// </summary>
        /// <param name="context"></param>
        /// <param name="programId"></param>
        /// <returns></returns>
        public static async Task <SnapshotGraphDTO> CreateGetProgramParticipantsByYearQuery(EcaContext context, IEnumerable <int> programIds)
        {
            Contract.Requires(context != null, "The context must not be null.");
            var pby = await context.Participants.Where(p => programIds.Contains(p.Project.ProgramId) &&
                                                       p.Project.StartDate.Year >= oldestDate.Year &&
                                                       p.Project.ProjectStatusId == ProjectStatus.Active.Id)
                      .GroupBy(x => x.Project.StartDate.Year).ToListAsync();

            SnapshotGraphDTO graphValues = new SnapshotGraphDTO
            {
                key    = "Participants",
                values = pby.Select(r => new KeyValuePair <int, int>(r.Key, r.Count())).OrderBy(p => p.Key).ToList()
            };

            return(graphValues);
        }