aboutsummaryrefslogtreecommitdiff
path: root/src/Models/Product.cs
blob: 2f092d132053fae0d3e17afc8f964fc86f2ea0b9 (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
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();
        }
    }
}