/// <summary> /// The multyuser view. /// </summary> /// <param name="projectId"> /// The project id. /// </param> /// <param name="userId"> /// The user id. /// </param> /// <param name="isOpenedProjects"> /// The is opened projects. /// </param> /// <returns> /// The System.Web.Mvc.ActionResult. /// </returns> public ActionResult MultiuserView(int projectId, int? userId, bool isOpenedProjects = true) { IList<HumanTask> unassignedHumanTasks = this.taskProcessor.GetUnAssignedTasksForProject(projectId).ToList(); List<TaskViewModel> unassignedTaskModel = unassignedHumanTasks.Select( task => new TaskViewModel { Task = task, TaskName = this.stringExtensions.Truncate(task.Name, 15), CreatorName = string.Empty, ViewStyle = true }).ToList(); var model = new ProjectViewModel { UsersTasks = new List<ManagerTasksViewModel>(), UnAssignedTasks = unassignedTaskModel, QuickTask = new HumanTask(), ProjectId = projectId, ChosenUserId = userId, ChosenUserTasks = new ManagerTasksViewModel(), NumberOfUsers = this.projectProcessor.GetUsersAndCreatorInProject(projectId).Count() }; model.QuickTask.ProjectId = projectId; var users = new List<User>(); users = this.projectProcessor.GetUsersAndCreatorInProject(projectId).Reverse().ToList(); foreach (var user in users) { IList<HumanTask> humanTasks = isOpenedProjects ? this.taskProcessor.GetAllOpenTasksForUserInProject(projectId, user.Id).ToList() : this.taskProcessor.GetAllClosedTasksForUserInProject(projectId, 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 = projectId, Tasks = taskModel }; model.UsersTasks.Add(managerModel); } if (userId != null) { IList<HumanTask> chosenTasks = isOpenedProjects ? this.taskProcessor.GetAllOpenTasksForUserInProject(projectId, (int)userId).ToList() : this.taskProcessor.GetAllClosedTasksForUserInProject(projectId, (int)userId).ToList(); List<TaskViewModel> chosenTaskModel = chosenTasks.Select( task => new TaskViewModel { Task = task, TaskName = this.stringExtensions.Truncate(task.Name, 15), CreatorName = string.Empty, ViewStyle = true }).ToList(); model.ChosenUserTasks.User = this.userProcessor.GetUser((int)userId); model.ChosenUserTasks.ProjectId = projectId; model.ChosenUserTasks.Tasks = chosenTaskModel; } return this.View(model); }
public ActionResult AllManagersWithTasks() { IList<HumanTask> unassignedHumanTasks = this.taskProcessor.GetUnassignedTasks().ToList(); List<TaskViewModel> unassignedTaskModel = unassignedHumanTasks.Select( task => new TaskViewModel { Task = task, CreatorName = string.Empty }).ToList(); var model = new ProjectViewModel { UsersTasks = new List<ManagerTasksViewModel>(), UnAssignedTasks = unassignedTaskModel }; var users = this.userRepository.GetAll(); foreach (var user in users) { IList<HumanTask> humanTasks = this.taskProcessor.GetTasksList(user.Id).ToList(); List<TaskViewModel> taskModel = humanTasks.Select( task => new TaskViewModel { Task = task, CreatorName = string.Empty }).ToList(); var managerModel = new ManagerTasksViewModel(); managerModel.User = user; managerModel.Tasks = taskModel; model.UsersTasks.Add(managerModel); } return this.View(model); }