diff options
author | Sergey Chebotar <s.chebotar@gmail.com> | 2022-12-20 12:27:47 +0300 |
---|---|---|
committer | Sergey Chebotar <s.chebotar@gmail.com> | 2022-12-20 12:27:47 +0300 |
commit | 73569a43644309d0342817580bcfd86c1face5b8 (patch) | |
tree | f3c6e15db82130b02ec8c3fa1b64674e6a9cf48d /src/Models/TargetPriceList.cs | |
parent | 3d186c22e8665b80839495fdcf4b176c2f3e03b9 (diff) |
Namespace refactoring
Diffstat (limited to 'src/Models/TargetPriceList.cs')
-rw-r--r-- | src/Models/TargetPriceList.cs | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/src/Models/TargetPriceList.cs b/src/Models/TargetPriceList.cs new file mode 100644 index 0000000..4754049 --- /dev/null +++ b/src/Models/TargetPriceList.cs @@ -0,0 +1,39 @@ +using Microsoft.Office.Interop.Excel; +using System; +using System.Linq; + +namespace RhSolutions.Models +{ + internal class TargetPriceList : PriceListBase + { + public Range OldSkuCell { get; private set; } + + public TargetPriceList(Workbook workbook) + { + if (workbook == null) + { + throw new ArgumentException("Невозможно открыть книгу шаблонного файла. " + + "Возможно открыт файл с именем, совпадающим с именем шаблонного файла."); + } + + Sheet = workbook.ActiveSheet; + Name = workbook.FullName; + + Range[] cells = new[] + { + AmountCell = Sheet.Cells.Find(PriceListHeaders.Amount), + SkuCell = Sheet.Cells.Find(PriceListHeaders.Sku), + GroupCell = Sheet.Cells.Find(PriceListHeaders.Group), + NameCell = Sheet.Cells.Find(PriceListHeaders.Name) + }; + + OldSkuCell = Sheet.Cells.Find(PriceListHeaders.OldSku); + + if (cells.Any(x => x == null)) + { + throw new ArgumentException($"Шаблон {Name} не является прайс-листом"); + } + } + } +} + |