filter out invalid organic manures
All checks were successful
FarmMaps.Develop/CarbonLib/pipeline/head This commit looks good

This commit is contained in:
2021-11-19 18:32:44 +01:00
parent 7dc5bb1b50
commit d96976c1f7

View File

@@ -156,7 +156,7 @@ namespace FarmMapsAPI.Carbon
Crop = cropYear.MiterraCropName,
CropRes = cropYear.CropRes,
OrganicManures =
cropYear.OrganicManures.Select(x => new OrganicManureType { Type = x.Type, Quantity = x.Quantity }).ToList(),
cropYear.OrganicManures.Where(y=>y.Quantity > 0 && !string.IsNullOrEmpty(y.Type)).Select(x => new OrganicManureType { Type = x.Type, Quantity = x.Quantity }).ToList(),
CropYield = cropYear.CropYield } }
});
}
@@ -170,7 +170,10 @@ namespace FarmMapsAPI.Carbon
{
foreach (var manure in cropYear.OrganicManures)
{
orgManure.Add(new OrganicManureType { Type = manure.Type, Quantity = manure.Quantity });
if (!string.IsNullOrEmpty(manure.Type) && manure.Quantity > 0)
{
orgManure.Add(new OrganicManureType { Type = manure.Type, Quantity = manure.Quantity });
}
}
}
var crop = mappedCropData.SingleOrDefault(x => x.Year == crops.Year);