forked from FarmMaps/FarmMapsApiClient
saves targetn information to a json file.
This commit is contained in:
@@ -3,6 +3,7 @@ using System.Globalization;
|
||||
using System.Threading.Tasks;
|
||||
using FarmmapsApi.Models;
|
||||
using FarmmapsApi.Services;
|
||||
using FarmmapsNbs.Models;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using static FarmmapsApi.Extensions;
|
||||
using static FarmmapsApiSamples.Constants;
|
||||
@@ -42,7 +43,7 @@ namespace FarmmapsNbs
|
||||
/// <param name="plantingDate">The date the crop is planted</param>
|
||||
/// <param name="measurementDate">The date the measurements are taken</param>
|
||||
/// <returns>The TargetN</returns>
|
||||
public async Task<double> CalculateTargetN(Item cropfieldItem, Item targetNItem, DateTime plantingDate,
|
||||
public async Task<TargetNData> CalculateTargetN(Item cropfieldItem, Item targetNItem, DateTime plantingDate,
|
||||
DateTime measurementDate, string inputType, string purposeType, int targetYield)
|
||||
{
|
||||
var nbsTargetNRequest = new TaskRequest {TaskType = VRANBS_TASK};
|
||||
@@ -66,14 +67,11 @@ namespace FarmmapsNbs
|
||||
if(itemTask.State == ItemTaskState.Error)
|
||||
{
|
||||
_logger.LogError($"Something went wrong with task execution: {itemTask.Message}");
|
||||
return 0;
|
||||
return null;
|
||||
}
|
||||
|
||||
var item = await _farmmapsApiService.GetItemAsync(targetNItem.Code);
|
||||
if (item.Data.ContainsKey("TargetN"))
|
||||
return item.Data.Value<double>("TargetN");
|
||||
|
||||
return 0;
|
||||
return item.Data.ToObject<TargetNData>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
Reference in New Issue
Block a user