public IReadOnlyList <string> CanAddProduct(Product product, int relativeWeight = 1)
        {
            List <string> errors = new List <string>();

            if (product == null)
            {
                errors.Add(ValidationMessage.MustSpecify("product"));
            }
            else
            {
                if (product.Id == 0)
                {
                    errors.Add(ValidationMessage.MustSpecify("product id"));
                }
                else if (IncludedProducts.FirstOrDefault(x => x.ProductId == product.Id) != null)
                {
                    errors.Add(ValidationMessage.AlreadyExists("product"));
                }
            }

            if (relativeWeight < 0)
            {
                errors.Add(ValidationMessage.Incorrect("relative weight"));
            }

            return(errors);
        }
 private void ValidateAndThrowRelativeWeight(int relativeWeight)
 {
     if (relativeWeight < 0)
     {
         throw new InvariantViolationException(
                   ValidationMessage.Incorrect("realtive weight"),
                   TariffErrorCode.IncorrectRelativeWeightValue);
     }
 }
        public IReadOnlyList <string> CanChangeProduct(Product product, int relativeWeight = 1)
        {
            List <string> errors = new List <string>();

            if (product == null)
            {
                errors.Add(ValidationMessage.MustSpecify("product"));
            }
            else
            {
                if (product.Id == 0)
                {
                    errors.Add(ValidationMessage.MustSpecify("product id"));
                }
            }

            if (relativeWeight < 0)
            {
                errors.Add(ValidationMessage.Incorrect("relative weight"));
            }

            return(errors);
        }