start & end date & geometry added to operations item and to cropfield characteristics item
This commit is contained in:
@@ -37,8 +37,11 @@ namespace FarmmapsApi.Services
|
||||
return await _farmmapsApiService.CreateItemAsync(cropfieldItemRequest);
|
||||
}
|
||||
|
||||
public async Task<Item> CreateOperationItemAsync(string cropRecordingItemCode, string data = "{}")
|
||||
public async Task<Item> CreateOperationItemAsync(string cropRecordingItemCode, int year,
|
||||
string fieldGeomJson, string data = "{}")
|
||||
{
|
||||
// not sure if here we also need to specify DataDate, DataEndDate & Geometry. Do it just in case
|
||||
var currentYear = new DateTime(year, 1, 1);
|
||||
JObject jdata = JObject.Parse(data);
|
||||
string name = string.Format($"CrpRec Operation, {jdata.GetValue("name")}");
|
||||
|
||||
@@ -47,21 +50,29 @@ namespace FarmmapsApi.Services
|
||||
ParentCode = cropRecordingItemCode,
|
||||
ItemType = CROPOP_ITEMTYPE,
|
||||
Name = name,
|
||||
DataDate = currentYear,
|
||||
DataEndDate = currentYear.AddYears(1).AddDays(-1),
|
||||
Data = jdata,
|
||||
Geometry = JObject.Parse(fieldGeomJson)
|
||||
};
|
||||
|
||||
return await _farmmapsApiService.CreateItemAsync(operationItemRequest);
|
||||
}
|
||||
public async Task<Item> CreateCropfieldCharacteristicItemAsync(string cropfieldItemCode, string data = "{}")
|
||||
public async Task<Item> CreateCropfieldCharacteristicItemAsync(string cropfieldItemCode, int year,
|
||||
string fieldGeomJson, string data = "{}")
|
||||
{
|
||||
// not sure if here we also need to specify DataDate, DataEndDate & Geometry. Do it just in case
|
||||
string name = "Cropfield characteristic";
|
||||
|
||||
var currentYear = new DateTime(year, 1, 1);
|
||||
ItemRequest cropfieldCharactericsticItemRequest = new ItemRequest()
|
||||
{
|
||||
ParentCode = cropfieldItemCode,
|
||||
ItemType = CROPCHAR_ITEMTYPE,
|
||||
Name = name,
|
||||
DataDate = currentYear,
|
||||
DataEndDate = currentYear.AddYears(1).AddDays(-1),
|
||||
Data = JObject.Parse(data),
|
||||
Geometry = JObject.Parse(fieldGeomJson)
|
||||
};
|
||||
|
||||
return await _farmmapsApiService.CreateItemAsync(cropfieldCharactericsticItemRequest);
|
||||
|
Reference in New Issue
Block a user