aboutsummaryrefslogtreecommitdiff
path: root/src/Services/RhDatabaseClient.cs
diff options
context:
space:
mode:
authorSergey Chebotar <s.chebotar@gmail.com>2022-12-22 16:00:38 +0300
committerSergey Chebotar <s.chebotar@gmail.com>2022-12-22 16:00:38 +0300
commitc47301c0db0235aecc15cedac2071ee556fef553 (patch)
treeaeb0878d005e3306af26f0382b79151f35fa0d00 /src/Services/RhDatabaseClient.cs
parentf267b27375a6d9577727b6df51f7550adc6480c0 (diff)
Try parse sku from input line on Rhsolutions function apply
Diffstat (limited to 'src/Services/RhDatabaseClient.cs')
-rw-r--r--src/Services/RhDatabaseClient.cs15
1 files changed, 4 insertions, 11 deletions
diff --git a/src/Services/RhDatabaseClient.cs b/src/Services/RhDatabaseClient.cs
index 8ce88f1..9664361 100644
--- a/src/Services/RhDatabaseClient.cs
+++ b/src/Services/RhDatabaseClient.cs
@@ -17,9 +17,9 @@ namespace RhSolutions.Services
{
string request = string.Empty;
- if (line.IsRehauSku())
+ if (Sku.TryParse(line, out var skus))
{
- request = @"https://rh.cebotari.ru/api/products/" + line;
+ request = @"https://rh.cebotari.ru/api/products/" + skus.FirstOrDefault().ToString();
}
else
@@ -31,7 +31,7 @@ namespace RhSolutions.Services
try
{
- response.EnsureSuccessStatusCode();
+ response.EnsureSuccessStatusCode();
string json = await response.Content.ReadAsStringAsync();
var product = JsonConvert.DeserializeObject<IEnumerable<Product>>(json)
.FirstOrDefault();
@@ -42,14 +42,7 @@ namespace RhSolutions.Services
}
else
{
- if (line.IsRehauSku())
- {
- return product.Name;
- }
- else
- {
- return $"{product.ProductSku} {product.Name}";
- }
+ return $"{product.ProductSku} {product.Name}";
}
}
catch