diff --git a/ISOv4Plugin/Mappers/CropTypeMapper.cs b/ISOv4Plugin/Mappers/CropTypeMapper.cs index 11a79e1..3288f58 100644 --- a/ISOv4Plugin/Mappers/CropTypeMapper.cs +++ b/ISOv4Plugin/Mappers/CropTypeMapper.cs @@ -72,8 +72,7 @@ public ISOCropType ExportCropType(Crop adaptCropType, ISOProductGroup cropTypePr IEnumerable cropVarieties = varietyProducts.Cast().Where(v => v.CropId == adaptCropType.Id.ReferenceId); if (cropVarieties.Any()) { - CropVarietyMapper varietyMapper = new CropVarietyMapper(TaskDataMapper); - isoCrop.CropVarieties = varietyMapper.ExportCropVarieties(cropVarieties).ToList(); + isoCrop.CropVarieties = TaskDataMapper.CropVarietyMapper.ExportCropVarieties(cropVarieties).ToList(); } } } @@ -112,8 +111,7 @@ public Crop ImportCropType(ISOCropType isoCropType) //Varieties if (isoCropType.CropVarieties.Any()) { - CropVarietyMapper varietyMapper = new CropVarietyMapper(TaskDataMapper); - varietyMapper.ImportCropVarieties(adaptCrop, isoCropType.CropVarieties); + TaskDataMapper.CropVarietyMapper.ImportCropVarieties(adaptCrop, isoCropType.CropVarieties); } return adaptCrop; diff --git a/ISOv4Plugin/Mappers/TaskDataMapper.cs b/ISOv4Plugin/Mappers/TaskDataMapper.cs index e5254e3..4ab6ecb 100644 --- a/ISOv4Plugin/Mappers/TaskDataMapper.cs +++ b/ISOv4Plugin/Mappers/TaskDataMapper.cs @@ -111,6 +111,19 @@ public ProductGroupMapper ProductGroupMapper } } + CropVarietyMapper _cropVarietyMapper; + public CropVarietyMapper CropVarietyMapper + { + get + { + if (_cropVarietyMapper == null) + { + _cropVarietyMapper = new CropVarietyMapper(this); + } + return _cropVarietyMapper; + } + } + GuidanceGroupMapper _guidanceGroupMapper; public GuidanceGroupMapper GuidanceGroupMapper {