Updated receiving of root items

This commit is contained in:
2022-02-28 14:29:56 +01:00
parent 5c38ff99dc
commit 0f9fe0a433
9 changed files with 38 additions and 25 deletions

View File

@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Net.Http.Headers;
@@ -95,7 +96,19 @@ namespace FarmmapsApi.Services
var jsonString = await response.Content.ReadAsStringAsync();
return JsonConvert.DeserializeObject<List<UserRoot>>(jsonString);
var roots = JsonConvert.DeserializeObject<List<UserRoot>>(jsonString);
roots.ForEach(v =>
{
v.Name = GetSuffixFromSystemItemCode(v.Code);
});
return roots;
}
private static string GetSuffixFromSystemItemCode(string itemCode)
{
string[] strArray = itemCode.Split(":");
return strArray.Length == 2 ? strArray[1] : throw new ArgumentException("No system item code :" + itemCode);
}
public async Task<Item> GetItemAsync(string itemCode, string itemType = null, JObject dataFilter = null)