refactored program

This commit is contained in:
2020-04-08 20:23:22 +02:00
parent 6dea82b973
commit 70a77f3472
18 changed files with 213 additions and 199 deletions

View File

@@ -6,6 +6,7 @@ using System.Threading.Tasks;
using FarmmapsApi.Models;
using Google.Apis.Upload;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json.Linq;
using static FarmmapsApi.Extensions;
using static FarmmapsApiSamples.Constants;
@@ -24,6 +25,23 @@ namespace FarmmapsApi.Services
_farmmapsApiService = farmmapsApiService;
}
public async Task<Item> CreateCropfieldItemAsync(string parentItemCode, string name, int year, string fieldGeomJson)
{
var currentYear = new DateTime(year, 1, 1);
var cropfieldItemRequest = new ItemRequest()
{
ParentCode = parentItemCode,
ItemType = CROPFIELD_ITEMTYPE,
Name = name,
DataDate = currentYear,
DataEndDate = currentYear.AddYears(1).AddDays(-1),
Data = JObject.Parse("{}"),
Geometry = JObject.Parse(fieldGeomJson)
};
return await _farmmapsApiService.CreateItemAsync(cropfieldItemRequest);
}
public async Task<Item> UploadDataAsync(UserRoot root, string itemType, string filePath, string itemName)
{
var startUpload = DateTime.UtcNow;