private static async Task <List <Row> > GetTaskAttributesData(List <TrainTaskAttribute> attributes, RowId parentId, ILogger logger) { var sqlRUsers = new UserRepository(logger); var sqlRTaskStatus = new TaskStatusRepository(logger); var sqlRTaskExecutors = new ExecutorRepository(logger); var sqlRTaskComment = new CommentRepository(logger); var sqlRCarriages = new CarriageRepository(logger); var sqlREquipmentModel = new EquipmentModelsRepository(logger); var sqlREquipment = new EquipmentRepository(logger); var sqlRTrains = new TrainRepository(logger); var sqlRTask = new TaskRepository(logger); var sqlRFault = new FaultsRepository(logger); var rows = new List <Row>(); foreach (var attribute in attributes) { var task = await sqlRTask.ById(attribute.TrainTaskId); var currentTaskStatus = (await sqlRTaskStatus.ByTaskId(attribute.TrainTaskId)).Last(); var carriage = await sqlRCarriages.ById(task.CarriageId); var user = GetUserById(sqlRUsers, task.UserId); var taskExecutor = (await sqlRTaskExecutors.GetByTaskId(task.Id)).Last(); var equipmentModel = await sqlREquipmentModel.ById(task.EquipmentModelId); var equipment = await sqlREquipment.ById(equipmentModel.EquipmentId); var lastComment = (await sqlRTaskComment.GetByTaskId(task.Id)).LastOrDefault(); var fault = new Fault();; if (attribute.FaultId != null) { fault = await sqlRFault.ById(attribute.FaultId.Value); } var updateData = GetTaskLastUpdate(lastComment, taskExecutor, currentTaskStatus); var toadd = new Row { Id = new RowId(attribute.Id, 3), HasItems = false.ToString(), ParentId = parentId, //Ид Col0 = task.Id.ToString(), //Статус Col1 = GetStringTaskStatus(currentTaskStatus.Status), //Тип Col2 = GetStringTaskType(task.TaskType), //Состав Col3 = GetTrainById(sqlRTrains, carriage.TrainId).Name, //Инициатор Col4 = user.Name, //Исполнитель Col5 = GetStringBrigadeType(taskExecutor.BrigadeType), //Дата Col6 = task.CreateDate.ToStringDateTime(), ////Вагон Col7 = carriage.Number.ToString(), //Оборудование Col8 = equipment.Name, ////Типовая Неисправность Col9 = fault?.Name, //Обновлено Col10 = updateData?.Date.ToStringDateTime(), //Обновил Col11 = updateData?.User.Name }; toadd.AdditionalProperty = new AdditionalProperty { TaskId = task.Id }; rows.Add(toadd); } return(rows); }