Return parsed sku while awaiting database response

This commit is contained in:
Sergey Chebotar 2022-12-28 15:26:41 +03:00
parent 677424f16e
commit 2506f0fe09

View File

@ -1,5 +1,7 @@
using ExcelDna.Integration; using ExcelDna.Integration;
using RhSolutions.Models;
using RhSolutions.Services; using RhSolutions.Services;
using System.Linq;
namespace RhSolutions.AddIn namespace RhSolutions.AddIn
{ {
@ -15,14 +17,31 @@ namespace RhSolutions.AddIn
return RhDatabaseClient.GetProduct(line).GetAwaiter().GetResult(); return RhDatabaseClient.GetProduct(line).GetAwaiter().GetResult();
}); });
string parsedSku = Sku.TryParse(line, out var skus)
? skus.First().ToString() : string.Empty;
if (result == null) if (result == null)
{ {
return ExcelError.ExcelErrorNA; if (string.IsNullOrEmpty(parsedSku))
{
return ExcelError.ExcelErrorNA;
}
else
{
return skus.First().ToString();
}
} }
if (result.Equals(ExcelError.ExcelErrorNA)) if (result.Equals(ExcelError.ExcelErrorNA))
{ {
return "Загрузка..."; if (string.IsNullOrEmpty(parsedSku))
{
return "Загрузка...";
}
else
{
return skus.First().ToString();
}
} }
return result; return result;