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