FarmMapsApiClient/FarmmapsHaulmkilling/HaulmkillingService.cs

36 lines
1.2 KiB
C#
Raw Normal View History

using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using FarmmapsApi.Services;
using FarmmapsHaulmkilling.Models;
using Microsoft.Extensions.Logging;
2020-04-22 10:51:53 +00:00
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;
}
2020-04-22 10:51:53 +00:00
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;
}
2020-04-22 10:51:53 +00:00
}
}