コード例 #1
0
        /// <summary>
        /// Deletes a customized product from a customized product collection
        /// </summary>
        /// <param name="modelView"> model view with the necessary information to perform the request</param>
        public static void delete(DeleteCustomizedProductFromCustomizedProductCollectionModelView modelView)
        {
            CustomizedProductCollectionRepository customizedProductCollectionRepository =
                PersistenceContext.repositories()
                .createCustomizedProductCollectionRepository();

            CustomizedProductCollection customizedProductCollection =
                customizedProductCollectionRepository.find(modelView.customizedProductCollectionId);

            checkIfCustomizedProductCollectionWasFound(customizedProductCollection, modelView.customizedProductCollectionId);

            CustomizedProduct customizedProduct =
                PersistenceContext.repositories()
                .createCustomizedProductRepository()
                .find(modelView.customizedProductId);

            if (customizedProduct == null)
            {
                throw new ArgumentException(
                          string.Format(
                              UNABLE_TO_FIND_CUSTOMIZED_PRODUCT,
                              modelView.customizedProductId)
                          );
            }

            customizedProductCollection.removeCustomizedProduct(customizedProduct);

            customizedProductCollectionRepository.update(customizedProductCollection);
        }
コード例 #2
0
        public void ensureRemovedCustomizedProductWorksForExistingProduct()
        {
            CustomizedProduct        cp   = buildFinishedCustomizedProductInstance();
            List <CustomizedProduct> list = new List <CustomizedProduct>();

            list.Add(cp);

            CustomizedProductCollection instance = new CustomizedProductCollection("Mario", list);

            instance.removeCustomizedProduct(cp);

            Assert.Empty(instance.collectionProducts);
        }