public static List <ResponseGetTaskByUserId> GetAllTasksByUserId(int userId) { List <TasksDTO> arrTasks = TasksDAL.GetAllTasksByUserId(userId); List <ResponseGetTaskByUserId> arrFinal = new List <ResponseGetTaskByUserId>(); // add partner for (int i = 0; i < arrTasks.Count; i++) { DataTable partners = UsersBLL.getListUserOfTask(arrTasks[i].ID); ResponseGetTaskByUserId temp = new ResponseGetTaskByUserId(); temp.ID = arrTasks[i].ID; temp.Title = arrTasks[i].Title; temp.startDate = arrTasks[i].startDate; temp.endDate = arrTasks[i].endDate; temp.Status = arrTasks[i].Status; temp.Private = arrTasks[i].Private; temp.OwnerId = getOwnerByTaskId(arrTasks[i].ID); temp.Partners = partners; arrFinal.Add(temp); } return(arrFinal); }