public OverviewModel ProjectOverview(int Id) { OverviewModel model; int userId = int.Parse(User.Identity.GetProjectUserId()); var managerTask = new TaskManager(); var managerProject = new ProjectUserManager(); var tasks = managerTask.GetTasksForProject(Id); int tasksDone = tasks.Where(t => t.State == managerTask.GetDoneStateId()).Count(); int tasksActive = tasks.Where(t => t.State == managerTask.GetActiveStateId()).Count(); int tasksUnassigned = managerTask.GetUnassignedTasks(Id).Count(); double workHours = managerTask.GetAllWorkTimeForProject(Id) .Sum(w => w.EndTime.Subtract(w.StartTime).TotalSeconds); var users = managerProject.GetUsersForProject(Id); List<string> devs = new List<string>(); foreach (var u in users) { devs.Add(u.UserName); } var project = managerProject.GetProject(Id); var projectLeaderName = managerProject.GetProjectLeader(Id).UserName; model = new OverviewModel( project.Id, project.Name, project.Description, project.Deadline, devs, tasksDone, tasksActive, tasksUnassigned, (int)(workHours / 3600), projectLeaderName); return model; }
private PartialViewResult ShowOverview(int projectId) { OverviewModel model; int userId = int.Parse(User.Identity.GetProjectUserId()); var managerTask = new TaskManager(); var managerProject = new ProjectUserManager(); var tasks = managerTask.GetTasksForProject(projectId); ViewData["isLeader"] = managerProject.IsLeader(userId, projectId); int tasksDone = tasks.Where(t => t.State == managerTask.GetDoneStateId()).Count(); int tasksActive = tasks.Where(t => t.State == managerTask.GetActiveStateId()).Count(); int tasksUnassigned = managerTask.GetUnassignedTasks(projectId).Count(); double workHours = managerTask.GetAllWorkTimeForProject(projectId) .Sum(w => w.EndTime.Subtract(w.StartTime).TotalSeconds); var users = managerProject.GetUsersForProject(projectId); List<string> devs = new List<string>(); foreach (var u in users) { devs.Add(u.UserName); } var project = managerProject.GetProject(projectId); var projectLeaderName = managerProject.GetProjectLeader(projectId).UserName; model = new OverviewModel( project, devs, tasksDone, tasksActive, tasksUnassigned, (int)(workHours / 3600), projectLeaderName); return PartialView("_Overview", model); }