aboutsummaryrefslogtreecommitdiff
path: root/src/PriceListTools/Position.cs
blob: 8ae5863646b2e7b651599db6e402e9f85e2347da (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
using System.Linq;

namespace RhSolutions.PriceListTools
{
    public class Position
    {
        public string Group { get; private set; }
        public string Sku { get; private set; }
        public string Name { get; private set; }

        public Position(string group, string sku, string name)
        {
            Group = group;
            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 string.Concat(properties.Where(p => p != null)).GetHashCode();
        }
    }
}