BinaryStudio.TaskManager.Web.Controllers.ProjectController.Project C# (CSharp) Method

Project() public method

The project.
public Project ( int id, int userId, bool isOpenedProjects = true ) : System.Web.Mvc.ActionResult
id int /// The id. ///
userId int /// The user id. ///
isOpenedProjects bool /// The is opened projects. ///
return System.Web.Mvc.ActionResult
        public ActionResult Project(int id, int? userId, bool isOpenedProjects = true)
        {
            IList<HumanTask> unassignedHumanTasks = this.taskProcessor.GetUnAssignedTasksForProject(id).ToList();
            List<TaskViewModel> unassignedTaskModel =
                unassignedHumanTasks.Select(
                    task =>
                    new TaskViewModel
                    {
                        Task = task,
                        TaskName = this.stringExtensions.Truncate(task.Name, 15),
                        CreatorName = string.Empty
                    }).ToList();
            var model = new ProjectViewModel
            {
                UsersTasks = new List<ManagerTasksViewModel>(),
                UnAssignedTasks = unassignedTaskModel,
                QuickTask = new HumanTask(),
                ProjectId = id,
                ChosenUserId = userId,
                ChosenUserTasks = new ManagerTasksViewModel(),
                NumberOfUsers = this.projectProcessor.GetUsersAndCreatorInProject(id).Count()
            };
            model.QuickTask.ProjectId = id;

            var users = new List<User>();
            users = this.projectProcessor.GetUsersAndCreatorInProject(id).Reverse().ToList();
            foreach (var user in users)
            {
                IList<HumanTask> humanTasks = isOpenedProjects
                        ? this.taskProcessor.GetAllOpenTasksForUserInProject(id, user.Id).ToList()
                        : this.taskProcessor.GetAllClosedTasksForUserInProject(id, user.Id).ToList();
                List<TaskViewModel> taskModel =
                    humanTasks.Select(
                        task =>
                        new TaskViewModel
                        {
                            Task = task,
                            TaskName = this.stringExtensions.Truncate(task.Name, 15),
                            CreatorName = string.Empty
                        }).ToList();
                var managerModel = new ManagerTasksViewModel
                {
                    User = user,
                    ProjectId = id,
                    Tasks = taskModel
                };
                model.UsersTasks.Add(managerModel);
            }

            if (userId != null)
            {
                IList<HumanTask> chosenTasks = isOpenedProjects
                         ? this.taskProcessor.GetAllOpenTasksForUserInProject(id, (int)userId).ToList()
                         : this.taskProcessor.GetAllClosedTasksForUserInProject(id, (int)userId).ToList();
                List<TaskViewModel> chosenTaskModel =
                    chosenTasks.Select(
                        task =>
                        new TaskViewModel
                        {
                            Task = task,
                            TaskName = this.stringExtensions.Truncate(task.Name, 15),
                            CreatorName = string.Empty,
                            ViewStyle = false
                        }).ToList();
                model.ChosenUserTasks.User = this.userProcessor.GetUser((int)userId);
                model.ChosenUserTasks.ProjectId = id;
                model.ChosenUserTasks.Tasks = chosenTaskModel;                
            }

            return this.View(model);
        }