public IEnumerable <TaskViewModel> GetAllTaskDetails()
        {
            var parentTasks = _parentTaskBusiness
                              .GetAllParentTaskDetail()
                              .ToList();

            var projects = _projectBusiness.GetAllProjectDetail();
            var tasks    = _taskRepository.GetAllRecord();
            var users    = _userRepository.GetAllRecord();

            var models = new List <TaskViewModel>();

            foreach (var task in tasks)
            {
                var parentTaskName = string.Empty;
                var status         = "No";
                var projectName    = string.Empty;
                var managerName    = string.Empty;
                var managerId      = 0;

                var pt = parentTasks.FirstOrDefault(p => p.ParentTaskId == task.ParentTaskId);
                if (pt != null)
                {
                    parentTaskName = pt.ParentTaskName;
                }

                var project = projects.FirstOrDefault(p => p.ProjectId == task.ProjectId);
                if (project != null)
                {
                    projectName = project.ProjectName;
                }

                var user = users.FirstOrDefault(p => p.TaskId == task.TaskId);
                if (user != null)
                {
                    managerName = string.Format("{0} {1}", user.FirstName, user.LastName);
                    managerId   = user.UserId;
                }

                models.Add(new TaskViewModel
                {
                    TaskId         = task.TaskId,
                    TaskName       = task.Title,
                    ParentTaskName = parentTaskName,
                    ParentTaskId   = task.ParentTaskId,
                    StartDate      = task.StartDate,
                    EndDate        = task.EndDate,
                    ProjectId      = task.ProjectId,
                    ProjectName    = projectName,
                    Priority       = task.Priority,
                    ManagerId      = managerId,
                    ManagerName    = managerName,
                    Status         = string.IsNullOrEmpty(task.Status) ? status : task.Status
                });
            }

            return(models);
        }
Example #2
0
 public IEnumerable <ProjectViewModel> GetAll()
 {
     return(ProjectDetailsBL.GetAllProjectDetail());
 }