Esempio n. 1
0
        public IEnumerable <Hourage> GetUserHourageRecordsWithProject(string userId)
        {
            var dbHourageRecords = _hourageManagement.GetUserHourageRecordsWithProject(userId);
            var records          = Mapper.Map <IEnumerable <HourageEntity>, IEnumerable <Hourage> >(dbHourageRecords);

            return(records);
        }
Esempio n. 2
0
        public IEnumerable <ProjectWithTotalHours> GetUserProjectsWithOverallTime(string userId)
        {
            var projectsUserTakePart     = _projectManagement.GetProjectsUserTakePart(userId);
            var houragesGroupedByProject = _hourageManagement.GetUserHourageRecordsWithProject(userId)
                                           .GroupBy(h => h.Project)
                                           .Select(hg =>
                                                   new
            {
                Project    = hg.Key,
                TotalHours = hg.Sum(r => r.Hours)
            });
            var projectsWithTotalHours = from pu in projectsUserTakePart
                                         join hourageRecord in houragesGroupedByProject on pu equals hourageRecord.Project into allProjects
                                         from p in allProjects.DefaultIfEmpty()
                                         select new { Project = pu, TotalHours = p?.TotalHours ?? 0 };

            var result = projectsWithTotalHours.Select(h => new ProjectWithTotalHours
            {
                Project = Mapper.Map <Project>(h.Project),
                Hours   = h.TotalHours
            });

            return(result);
        }