using System.Collections.Generic;
using System.Text;
using Gremlin.GremlinData.EntityClasses;

namespace Gremlin.GremlinData.DBClasses
{
    public class ProductEqualityComparer : IEqualityComparer<Product>
    {
        public bool Equals(Product product1, Product product2)
        {
            return !((product1 != null || product2 != null)
                && !(product1 != null && product2 != null
                && product1.ProductNumber == product2.ProductNumber
                && product1.OptionNumber == product2.OptionNumber
                && product1.BreakRangeFrom == product2.BreakRangeFrom
                && product1.BreakRangeTo == product2.BreakRangeTo));
        }

        public int GetHashCode(Product product)
        {
            StringBuilder sb = new();
            _ = sb.Append(product.ProductNumber).Append(product.OptionNumber).Append(product.BreakRangeFrom).Append(product.BreakRangeTo);
            return sb.ToString().GetHashCode();
        }
    }
}
