diff --git a/CarbonCalculation.cs b/CarbonCalculation.cs index a549e38..89f5e03 100644 --- a/CarbonCalculation.cs +++ b/CarbonCalculation.cs @@ -156,7 +156,7 @@ namespace FarmMapsAPI.Carbon Crop = cropYear.MiterraCropName, CropRes = cropYear.CropRes, OrganicManures = - cropYear.OrganicManures.Where(y=>y.Quantity > 0 && !string.IsNullOrEmpty(y.Type)).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.HasValue? x.Quantity.Value : 0 }).ToList(), CropYield = cropYear.CropYield, Irrigation = crops.Irrigations} } }); @@ -171,9 +171,9 @@ namespace FarmMapsAPI.Carbon { foreach (var manure in cropYear.OrganicManures) { - if (!string.IsNullOrEmpty(manure.Type) && manure.Quantity > 0) + if (!string.IsNullOrEmpty(manure.Type) && manure.Quantity.HasValue && manure.Quantity > 0) { - orgManure.Add(new OrganicManureType { Type = manure.Type, Quantity = manure.Quantity }); + orgManure.Add(new OrganicManureType { Type = manure.Type, Quantity = manure.Quantity.HasValue ? manure.Quantity.Value : 0 }); } } } @@ -244,7 +244,7 @@ namespace FarmMapsAPI.Carbon { carbon_organicmatter_factor = 1; } - + ////////////////////////////////////////////// // precalculations ////////////////////////////////////////////// @@ -276,7 +276,9 @@ namespace FarmMapsAPI.Carbon { soilPropertyDepth10 = true; } - //FSA todo: different corrections for depth10 (10, 25, 30 cm) + // Different corrections for depth (10, 25, 30 cm) + // depth of 10cm has same result as previous checkbox (sample taken at 10cm) + parameterSet.LayerDepth = item.Value.Depth.HasValue? item.Value.Depth.Value : parameterSet.LayerDepth; if (initialSoil == "Temp_gras" && soilPropertyDepth10) { oM_corr_SoilType.Add((item.Key, soilOfItem), item.Value.OM_Cont * 0.97); diff --git a/Models/FarmMapsCarbonRequest.cs b/Models/FarmMapsCarbonRequest.cs index ce19286..fcd2e29 100644 --- a/Models/FarmMapsCarbonRequest.cs +++ b/Models/FarmMapsCarbonRequest.cs @@ -70,7 +70,7 @@ namespace FarmMapsAPI.Carbon.Models [Required] public string Type { get; set; } [Required] - public double Quantity { get; set; } + public double? Quantity { get; set; } } public class SoilPropertyFarmMaps