Beispiel #1
0
        public JsonResult GetProjectTimebreakdown(int projectId)
        {
            var tsManager = new TimesheetManager();

            ProjectTimeBreakdown timeBreakdown = new ProjectTimeBreakdown();

            var groupedByWorkType = tsManager.GetTimeEntrySummaries(projectId)
                                    .GroupBy(i => i.worktypeid)
                                    .Select(i => new
            {
                Id            = i.Key,
                WorkType      = i.First().worktypename,
                WorkTypeTotal = i.Sum(s => s.entryHours.Value)
            })
                                    .OrderBy(i => i.Id);

            timeBreakdown.WorkTypes = groupedByWorkType.Select(i => i.WorkType).ToList();
            timeBreakdown.Hours     = groupedByWorkType.Select(i => i.WorkTypeTotal).ToList();

            return(Json(timeBreakdown, JsonRequestBehavior.AllowGet));
        }
Beispiel #2
0
        private Project GetProject(int id, DateTime?start = null, DateTime?end = null)
        {
            Project project = Mapper.Map <Project>(_projectManager.GetProject(id));

            project.JobYears = _projectManager.GetJobYears()
                               .Select(i => Mapper.Map <Models.Project.JobYear>(i))
                               .ToList();
            project.ProjectTypes = _projectManager.GetProjectTypes()
                                   .Select(i => Mapper.Map <Models.Project.ProjectType>(i))
                                   .ToList();

            var tsManager = new TimesheetManager();

            project.TimeEntrySummaries = tsManager.GetTimeEntrySummaries(id, start, end)
                                         .Select(i => Mapper.Map <Models.Timesheet.TimeEntrySummary>(i))
                                         .OrderByDescending(i => i.EndingDate)
                                         .ToList();

            if (project.TimeEntrySummaries != null)
            {
                project.InternalHours  = project.TimeEntrySummaries.Sum(j => j.EntryHours);
                project.InternalAmount = project.TimeEntrySummaries.Sum(j => j.InternalAmount);
                if (project.ContractedAmount.HasValue)
                {
                    project.InternalDifference      = project.ContractedAmount.Value - project.InternalAmount;
                    project.InternalDifferenceRatio = (float)(project.InternalAmount / project.ContractedAmount.Value);
                }
            }
            else
            {
                project.InternalHours  = 0;
                project.InternalAmount = 0;
            }

            return(project);
        }