forked from FarmMaps/FarmMapsApiClient
		
	refactored program
This commit is contained in:
		@@ -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;
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user