public ActionResult fetchPossibleComponents(long customizedProductId, long slotId)
 {
     try {
         FindPossibleComponentsModelView findPossibleComponents = new FindPossibleComponentsModelView();
         findPossibleComponents.customizedProductID = customizedProductId;
         findPossibleComponents.slotID = slotId;
         GetPossibleComponentsModelView possibleComponents = new core.application.CustomizedProductController().fetchPossibleComponents(findPossibleComponents);
         return(Ok(possibleComponents));
     } catch (ResourceNotFoundException e) {
         return(NotFound(new SimpleJSONMessageService(e.Message)));
     } catch (InvalidOperationException ex) {
         return(BadRequest(new SimpleJSONMessageService(ex.Message)));
     } catch (Exception) {
         return(StatusCode(500, new SimpleJSONMessageService(UNEXPECTED_ERROR)));
     }
 }
        /// <summary>
        /// Retrieves all possible components for a certain slot of a customized product
        /// </summary>
        /// <param name="customizedProductID">customized product to base restrictions on</param>
        /// <param name="slotID">selected slot</param>
        /// <returns>possible components for selected slot</returns>
        public GetPossibleComponentsModelView fetchPossibleComponents(FindPossibleComponentsModelView findComponentsMV)
        {
            CustomizedProductRepository customizedProductRepository = PersistenceContext.repositories().createCustomizedProductRepository();
            CustomizedProduct           customizedProduct           = customizedProductRepository.find(findComponentsMV.customizedProductID);

            if (customizedProduct == null)
            {
                throw new ResourceNotFoundException(string.Format(ERROR_UNABLE_TO_FIND_CUSTOMIZED_PRODUCT_BY_ID, findComponentsMV.customizedProductID));
            }

            Slot slot = customizedProduct.slots.Where(s => s.Id == findComponentsMV.slotID).SingleOrDefault();

            if (slot == null)
            {
                throw new ResourceNotFoundException(string.Format(ERROR_UNABLE_TO_FIND_SLOT, findComponentsMV.slotID));
            }
            List <Product> restrictedProducts = (List <Product>)customizedProduct.product.getRestrictedComponents(customizedProduct, slot);

            if (Collections.isEnumerableNullOrEmpty(restrictedProducts))
            {
                throw new InvalidOperationException(NO_POSSIBLE_COMPONENTS);
            }
            return(ProductModelViewService.possibleComponentsFromCollection(restrictedProducts));
        }