forked from FarmMaps/FarmMapsApiClient
36 lines
1.2 KiB
C#
36 lines
1.2 KiB
C#
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
using FarmmapsApi.Services;
|
|
using FarmmapsHaulmkilling.Models;
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
namespace FarmmapsHaulmkilling
|
|
{
|
|
public class HaulmkillingService
|
|
{
|
|
private readonly ILogger<HaulmkillingService> _logger;
|
|
private readonly FarmmapsApiService _farmmapsApiService;
|
|
private readonly GeneralService _generalService;
|
|
|
|
public HaulmkillingService(ILogger<HaulmkillingService> logger, FarmmapsApiService farmmapsApiService,
|
|
GeneralService generalService)
|
|
{
|
|
_logger = logger;
|
|
_farmmapsApiService = farmmapsApiService;
|
|
_generalService = generalService;
|
|
}
|
|
|
|
public async Task<List<HaulmkillingAgent>> GetHaulmkillingAgents()
|
|
{
|
|
var itemType = "vnd.farmmaps.package.vra.haulmkilling";
|
|
var vraHerbicideDataItems = await _farmmapsApiService.GetItemsAsync(string.Empty, itemType);
|
|
|
|
var item = vraHerbicideDataItems.FirstOrDefault();
|
|
if (item == null)
|
|
return null;
|
|
|
|
return item.Data.ContainsKey("agents") ? item.Data["agents"].ToObject<List<HaulmkillingAgent>>() : null;
|
|
}
|
|
}
|
|
} |