diff options
author | Sergey Chebotar <s.chebotar@gmail.com> | 2023-04-20 06:58:27 +0300 |
---|---|---|
committer | Sergey Chebotar <s.chebotar@gmail.com> | 2023-04-20 06:58:27 +0300 |
commit | 13996f03816f658d1c1f034964f7381a991d8bde (patch) | |
tree | 086c14894ed14763ec6ba71b6cbbf2d77ee00e5e | |
parent | 8e820c4cd994d71a52304a4e49478c6ccd06d35e (diff) |
Change internal Product class to nuget library
-rw-r--r-- | RhSolutions.AddIn/AddIn/RhSolutionsFunction.cs | 2 | ||||
-rw-r--r-- | RhSolutions.AddIn/Models/Product.cs | 35 | ||||
-rw-r--r-- | RhSolutions.AddIn/RhSolutions.AddIn.csproj | 2 | ||||
-rw-r--r-- | RhSolutions.AddIn/Services/RhDatabaseClient.cs | 2 | ||||
-rw-r--r-- | RhSolutions.AddIn/Services/RhExcelReader.cs | 4 |
5 files changed, 5 insertions, 40 deletions
diff --git a/RhSolutions.AddIn/AddIn/RhSolutionsFunction.cs b/RhSolutions.AddIn/AddIn/RhSolutionsFunction.cs index d45ed10..d7631f3 100644 --- a/RhSolutions.AddIn/AddIn/RhSolutionsFunction.cs +++ b/RhSolutions.AddIn/AddIn/RhSolutionsFunction.cs @@ -14,7 +14,7 @@ public class RhSolutionsFunction { IDatabaseClient databaseClient = RhSolutionsAddIn.ServiceProvider.GetService<IDatabaseClient>(); - Sku.TryParse(line, out var skus); + ProductSku.TryParse(line, out var skus); if (ExcelAsyncUtil.Run("Database request", line, delegate { diff --git a/RhSolutions.AddIn/Models/Product.cs b/RhSolutions.AddIn/Models/Product.cs deleted file mode 100644 index 2f092d1..0000000 --- a/RhSolutions.AddIn/Models/Product.cs +++ /dev/null @@ -1,35 +0,0 @@ -using System.Linq; - -namespace RhSolutions.Models -{ - public class Product - { - public string ProductLine { get; set; } - public string ProductSku { get; set; } - public string Name { get; set; } - - public override bool Equals(object obj) - { - if (obj as Product == null) - return false; - - Product other = obj as Product; - - return ProductLine == other.ProductLine && - ProductSku == other.ProductSku && - Name == other.Name; - } - - public override int GetHashCode() - { - string[] properties = new[] - { - ProductLine, - ProductSku, - Name - }; - - return string.Concat(properties.Where(p => p != null)).GetHashCode(); - } - } -}
\ No newline at end of file diff --git a/RhSolutions.AddIn/RhSolutions.AddIn.csproj b/RhSolutions.AddIn/RhSolutions.AddIn.csproj index d5ae431..c77a8b8 100644 --- a/RhSolutions.AddIn/RhSolutions.AddIn.csproj +++ b/RhSolutions.AddIn/RhSolutions.AddIn.csproj @@ -36,7 +36,7 @@ <PackageReference Include="Microsoft.Extensions.Http" Version="7.0.0" /> <PackageReference Include="netDxf" Version="2022.11.2" /> <PackageReference Include="Newtonsoft.Json" Version="13.0.3" /> - <PackageReference Include="RhSolutions.Sku" Version="0.1.1" /> + <PackageReference Include="RhSolutions.Sku" Version="0.1.5" /> <PackageReference Include="System.Buffers" Version="4.5.1" /> <PackageReference Include="System.Threading.Tasks.Extensions" Version="4.5.4" /> </ItemGroup> diff --git a/RhSolutions.AddIn/Services/RhDatabaseClient.cs b/RhSolutions.AddIn/Services/RhDatabaseClient.cs index 8edbafc..520915d 100644 --- a/RhSolutions.AddIn/Services/RhDatabaseClient.cs +++ b/RhSolutions.AddIn/Services/RhDatabaseClient.cs @@ -19,7 +19,7 @@ public class RhDatabaseClient : IDatabaseClient { string request; - if (Sku.TryParse(line, out var skus)) + if (ProductSku.TryParse(line, out var skus)) { request = @"https://rh.cebotari.ru/api/products/" + skus.FirstOrDefault().ToString(); } diff --git a/RhSolutions.AddIn/Services/RhExcelReader.cs b/RhSolutions.AddIn/Services/RhExcelReader.cs index 0192b39..3face65 100644 --- a/RhSolutions.AddIn/Services/RhExcelReader.cs +++ b/RhSolutions.AddIn/Services/RhExcelReader.cs @@ -38,7 +38,7 @@ public class RhExcelReader : IExcelReader, IDisposable { object currentCell = cells[row, column]; - if (Sku.TryParse(currentCell.ToString(), out var validSku)) + if (ProductSku.TryParse(currentCell.ToString(), out var validSku)) { currentSku = validSku.FirstOrDefault().ToString() ?? null; } @@ -112,7 +112,7 @@ public class RhExcelReader : IExcelReader, IDisposable if (programLine == null || name == null || sku == null) continue; - if (!Sku.TryParse(sku.ToString(), out _)) + if (!ProductSku.TryParse(sku.ToString(), out _)) continue; Product p = new() |