/**
         * Method that will add new configured products to the collection with the passed reference.
         * It is assumed that a list with 1 or more objects is received.
         *
         * Validations performed:
         * 1. Validation of the passed collection's reference (database);
         * 2. The received list has 1 or more elements.
         * FOREACH RECEIVED string (Configured Product reference) {
         * 3. Validation of current configured product reference (database);
         * 4. Validation of the existence of current configured product in the collection with the passed reference
         * 5. Validation for duplication between each configured product reference received
         */
        public ValidationOutput AddConfiguredProducts(string reference, IEnumerable <ConfiguredProductDto> enumerableConfiguredProduct)
        {
            //1.
            ValidationOutput validationOutput = new ValidationOutputNotFound();

            if (!CollectionExists(reference))
            {
                validationOutput.AddError("Reference of collection", "No collection with the reference '" + reference + "' exists in the system.");
                return(validationOutput);
            }

            Collection collectionToModify = _collectionRepository.GetByReference(reference);

            List <ConfiguredProductDto> configuredProductList = new List <ConfiguredProductDto>(enumerableConfiguredProduct);

            //2.
            validationOutput = new ValidationOutputBadRequest();
            if (configuredProductList.Count == 0)
            {
                validationOutput.AddError("Selected configured products", "No configured products were selected!");
                return(validationOutput);
            }

            List <string> configuredProductListToAdd = new List <string>();

            foreach (var configuredProduct in configuredProductList)
            {
                //3.
                if (!ConfiguredProductExists(configuredProduct.Reference))
                {
                    validationOutput.AddError("Reference of configured product", "No configured product with the reference '" + configuredProduct.Reference + "' exists in the system.");
                    return(validationOutput);
                }

                //4.
                if (collectionToModify.ConfiguredProductIsInCollection(configuredProduct.Reference))
                {
                    validationOutput.AddError("Configured product", "Configured product '" + configuredProduct.Reference + "' already belongs to collection with reference '" + reference + "'.");
                    return(validationOutput);
                }

                //5.
                if (configuredProductListToAdd.Contains(configuredProduct.Reference))
                {
                    validationOutput.AddError("Configured product", "Configured product '" + configuredProduct.Reference + "' is duplicated in the list of configured product selected!");
                    return(validationOutput);
                }

                configuredProductListToAdd.Add(configuredProduct.Reference);
            }

            foreach (var configuredProductToAdd in configuredProductListToAdd)
            {
                collectionToModify.AddConfiguredProduct(configuredProductToAdd);
            }

            validationOutput.DesiredReturn = configuredProductListToAdd;
            _collectionRepository.Update(collectionToModify);
            return(validationOutput);
        }