diff options
author | Sergey Chebotar <s.chebotar@gmail.com> | 2022-12-22 16:00:38 +0300 |
---|---|---|
committer | Sergey Chebotar <s.chebotar@gmail.com> | 2022-12-22 16:00:38 +0300 |
commit | c47301c0db0235aecc15cedac2071ee556fef553 (patch) | |
tree | aeb0878d005e3306af26f0382b79151f35fa0d00 /src/Services/RhDatabaseClient.cs | |
parent | f267b27375a6d9577727b6df51f7550adc6480c0 (diff) |
Try parse sku from input line on Rhsolutions function apply
Diffstat (limited to 'src/Services/RhDatabaseClient.cs')
-rw-r--r-- | src/Services/RhDatabaseClient.cs | 15 |
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 |