Position class Equals method override
This commit is contained in:
parent
5dcc91e4a1
commit
7fffd91c9b
@ -135,6 +135,7 @@ namespace RehauSku.PriceListTools
|
|||||||
protected int? GetPositionRow(Range range, string sku, string group)
|
protected int? GetPositionRow(Range range, string sku, string group)
|
||||||
{
|
{
|
||||||
Range found = range.Find(sku);
|
Range found = range.Find(sku);
|
||||||
|
string foundGroupValue;
|
||||||
|
|
||||||
if (found == null)
|
if (found == null)
|
||||||
{
|
{
|
||||||
@ -143,13 +144,16 @@ namespace RehauSku.PriceListTools
|
|||||||
|
|
||||||
int firstFoundRow = found.Row;
|
int firstFoundRow = found.Row;
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(group))
|
||||||
|
{
|
||||||
|
return found.Row;
|
||||||
|
}
|
||||||
|
|
||||||
while (true)
|
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) ||
|
if (group.Equals(foundGroupValue))
|
||||||
string.IsNullOrEmpty(groupCell.Value2.ToString()) ||
|
|
||||||
group.Equals(groupCell.Value2.ToString()))
|
|
||||||
{
|
{
|
||||||
return found.Row;
|
return found.Row;
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
namespace RehauSku.PriceListTools
|
using System.Linq;
|
||||||
|
|
||||||
|
namespace RehauSku.PriceListTools
|
||||||
{
|
{
|
||||||
public class Position
|
public class Position
|
||||||
{
|
{
|
||||||
@ -12,5 +14,29 @@
|
|||||||
Sku = sku;
|
Sku = sku;
|
||||||
Name = name;
|
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());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user