private PartialViewResult ShowTasks(int projectId)
        {
            List<TaskListElement> model = new List<TaskListElement>();

            int userId = int.Parse(User.Identity.GetProjectUserId());
            var manager = new TaskManager();

            int deletedId = manager.GetDeletedStateId();

            ViewData["projectId"] = projectId;
            ViewData["deletedId"] = deletedId;
            ViewData["isLeader"] = new ProjectUserManager().IsLeader(userId, projectId);
            ViewData["isDone"] = new ProjectUserManager().GetProject(projectId).Done;

            var tasks = manager.GetTasksForProject(projectId);

            foreach (var t in tasks)
            {
                var name = manager.GetTaskStateName(t.Id);

                var isCommented = manager.IsCommented(t.Id);

                var workHours = manager.GetAllWorkTimeForTask(t.Id)
                    .Sum(w => w.EndTime.Subtract(w.StartTime).TotalSeconds);

                var developers = manager.GetUsersForTask(t.Id);

                List<string> devs = new List<string>();
                foreach (var v in developers)
                {
                    devs.Add(v.UserName);
                }

                TaskListElement element = new TaskListElement(t, name, devs, (int)(workHours / 3600), isCommented);
                model.Add(element);
            }

            return PartialView("_Tasks", model);
        }
        public IEnumerable<TaskListElement> TaskList(int Id)
        {
            int userId = int.Parse(User.Identity.GetProjectUserId());

            List<TaskListElement> res = new List<TaskListElement>();
            var manager = new TaskManager();
            foreach (Task t in manager.GetTasksForProject(Id))
            {
                string stateName = manager.GetTaskStateName(t.State);

                IEnumerable<ProjectUser> devUsers = manager.GetUsersForTask(t.Id);
                List<string> devs = new List<string>();
                foreach (var v in devUsers)
                {
                    devs.Add(v.UserName);
                }

                var workHours = manager.GetAllWorkTimeForTask(t.Id)
                    .Sum(w => w.EndTime.Subtract(w.StartTime).TotalSeconds);

                bool hasComments = manager.IsCommented(t.Id);

                res.Add(new TaskListElement(t.Id,t.Name, stateName, devs, (int)(workHours / 3600), hasComments));
            }

            return res;
        }