aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/PriceListTools/AbstractTool.cs14
-rw-r--r--src/PriceListTools/Position.cs30
2 files changed, 37 insertions, 7 deletions
diff --git a/src/PriceListTools/AbstractTool.cs b/src/PriceListTools/AbstractTool.cs
index f312e95..0ffabd2 100644
--- a/src/PriceListTools/AbstractTool.cs
+++ b/src/PriceListTools/AbstractTool.cs
@@ -135,21 +135,25 @@ namespace RehauSku.PriceListTools
protected int? GetPositionRow(Range range, string sku, string group)
{
Range found = range.Find(sku);
+ string foundGroupValue;
if (found == null)
{
return null;
}
- int firstFoundRow = found.Row;
+ int firstFoundRow = found.Row;
+
+ if (string.IsNullOrEmpty(group))
+ {
+ return found.Row;
+ }
while (true)
{
- Range groupCell = TargetFile.Sheet.Cells[found.Row, TargetFile.GroupCell.Column];
+ foundGroupValue = TargetFile.Sheet.Cells[found.Row, TargetFile.GroupCell.Column].Value2.ToString();
- if (string.IsNullOrEmpty(group) ||
- string.IsNullOrEmpty(groupCell.Value2.ToString()) ||
- group.Equals(groupCell.Value2.ToString()))
+ if (group.Equals(foundGroupValue))
{
return found.Row;
}
diff --git a/src/PriceListTools/Position.cs b/src/PriceListTools/Position.cs
index 0863642..34b7b93 100644
--- a/src/PriceListTools/Position.cs
+++ b/src/PriceListTools/Position.cs
@@ -1,6 +1,8 @@
-namespace RehauSku.PriceListTools
+using System.Linq;
+
+namespace RehauSku.PriceListTools
{
- public class Position
+ public class Position
{
public string Group { get; private set; }
public string Sku { get; private set; }
@@ -12,5 +14,29 @@
Sku = sku;
Name = name;
}
+
+ public override bool Equals(object obj)
+ {
+ if (obj as Position == null)
+ return false;
+
+ Position other = obj as Position;
+
+ return Group == other.Group &&
+ Sku == other.Sku &&
+ Name == other.Name;
+ }
+
+ public override int GetHashCode()
+ {
+ string[] properties = new[]
+ {
+ Group,
+ Sku,
+ Name
+ };
+
+ return properties.Where(p => p != null).Sum(p => p.GetHashCode());
+ }
}
} \ No newline at end of file