コード例 #1
0
        public async Task<ActionResult> ProjectTotalHoursPerPeriod(SetPeriodViewModel model)
        {

            var m = (await db.Projects.SelectMany(p=>p.Activities).Finished().OnInterval(model.FinalDate, model.InitialDate).GroupBy(p => p.Project.Name).Select(p => new
            {
                Name = p.Key,
                WorkTimes = p.Select(a1 => a1.WorkingTime)
            }).ToListAsync());

            var result = m.Where(x => x.WorkTimes.Count() > 0).Select(a => new ProjectTotalHoursViewModel()
            {
                Name = a.Name,
                TotalHours = a.WorkTimes.Sum(t => t.TotalHours)
            }).ToList();

            model.ResultProjects = result;

            return View(model);


        }
コード例 #2
0
        public async Task<ActionResult> UserProductivityPerPeriod(SetPeriodViewModel model)
        {
            var m = (await db.Projects.SelectMany(p => p.Activities).Finished().OnInterval(model.FinalDate, model.InitialDate).GroupBy(a => a.AssignedUser)
                                                    .Select(ag => new
                                                    {
                                                        WorkingTimes = ag.Select(a1 => a1.WorkingTime),
                                                        UserName = ag.Key.UserName
                                                    })
                                            .ToListAsync());


            model.ResultUsers = m.Select(u => new UserTotalHoursViewModel()
            {
                Name = u.UserName,
                TotalHours = u.WorkingTimes.Sum(w => w.TotalHours)
            }).OrderByDescending(u => u.TotalHours).ToList();



            return View(model);


        }