Skip to content

Commit 695a277

Browse files
authored
Merge pull request #216 from knelson-farmbeltnorth/develop
Scoping issue with the CropVarietyMapper resulting in duplicate IDs
2 parents 45453e9 + 6be64bd commit 695a277

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

ISOv4Plugin/Mappers/CropTypeMapper.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,7 @@ public ISOCropType ExportCropType(Crop adaptCropType, ISOProductGroup cropTypePr
7272
IEnumerable<CropVarietyProduct> cropVarieties = varietyProducts.Cast<CropVarietyProduct>().Where(v => v.CropId == adaptCropType.Id.ReferenceId);
7373
if (cropVarieties.Any())
7474
{
75-
CropVarietyMapper varietyMapper = new CropVarietyMapper(TaskDataMapper);
76-
isoCrop.CropVarieties = varietyMapper.ExportCropVarieties(cropVarieties).ToList();
75+
isoCrop.CropVarieties = TaskDataMapper.CropVarietyMapper.ExportCropVarieties(cropVarieties).ToList();
7776
}
7877
}
7978
}
@@ -112,8 +111,7 @@ public Crop ImportCropType(ISOCropType isoCropType)
112111
//Varieties
113112
if (isoCropType.CropVarieties.Any())
114113
{
115-
CropVarietyMapper varietyMapper = new CropVarietyMapper(TaskDataMapper);
116-
varietyMapper.ImportCropVarieties(adaptCrop, isoCropType.CropVarieties);
114+
TaskDataMapper.CropVarietyMapper.ImportCropVarieties(adaptCrop, isoCropType.CropVarieties);
117115
}
118116

119117
return adaptCrop;

ISOv4Plugin/Mappers/TaskDataMapper.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,19 @@ public ProductGroupMapper ProductGroupMapper
111111
}
112112
}
113113

114+
CropVarietyMapper _cropVarietyMapper;
115+
public CropVarietyMapper CropVarietyMapper
116+
{
117+
get
118+
{
119+
if (_cropVarietyMapper == null)
120+
{
121+
_cropVarietyMapper = new CropVarietyMapper(this);
122+
}
123+
return _cropVarietyMapper;
124+
}
125+
}
126+
114127
GuidanceGroupMapper _guidanceGroupMapper;
115128
public GuidanceGroupMapper GuidanceGroupMapper
116129
{

0 commit comments

Comments
 (0)