Beispiel #1
0
        /// <summary>
        /// Returns an instance of GetAlgorithmModelView representing the instance of Algorithm.
        /// </summary>
        /// <param name="restrictionAlgorithm">RestrictionAlgorithm that matches the corresponding Algorithm.</param>
        /// <returns>GetAlgorithmModelView representing the instance of Algorithm.</returns>
        public GetAlgorithmModelView getAlgorithm(RestrictionAlgorithm restrictionAlgorithm)
        {
            //this throws ArgumentOutOfRangeException if the element is not recognized by the factory
            Algorithm algorithm = new AlgorithmFactory().createAlgorithm(restrictionAlgorithm);

            return(AlgorithmModelViewService.fromEntity(algorithm));
        }
        /// <summary>
        /// Creates a model view with a restriction basic information
        /// </summary>
        /// <param name="restriction">Restriction with the restriction being created the model view</param>
        /// <returns>GetBasicRestrictionModelView with the restriction basic information model view</returns>
        public static GetBasicRestrictionModelView fromEntityAsBasic(Restriction restriction)
        {
            if (restriction == null)
            {
                throw new ArgumentNullException(NULL_RESTRICTION);
            }

            GetBasicRestrictionModelView basicRestrictionModelView = new GetBasicRestrictionModelView();

            basicRestrictionModelView.id          = restriction.Id;
            basicRestrictionModelView.description = restriction.description;
            basicRestrictionModelView.algorithm   = AlgorithmModelViewService.fromEntityAsBasic(restriction.algorithm);
            return(basicRestrictionModelView);
        }
Beispiel #3
0
        /// <summary>
        /// Returns an instance of GetAllAlgorithmsModelView representing all the available types of Algorithm.
        /// </summary>
        /// <returns>GetAllAlgorithmsModelView representing all the available types of Algorithm.</returns>
        public GetAllAlgorithmsModelView getAllAlgorithms()
        {
            Array availableAlgorithms = Enum.GetValues(typeof(RestrictionAlgorithm));

            if (availableAlgorithms.Length == 0)
            {
                throw new ResourceNotFoundException(NO_ALGORITHMS_AVAILABLE);
            }

            GetAllAlgorithmsModelView allAlgorithmsModelView = new GetAllAlgorithmsModelView();

            foreach (RestrictionAlgorithm restrictionAlgorithm in availableAlgorithms)
            {
                Algorithm algorithm = new AlgorithmFactory().createAlgorithm(restrictionAlgorithm);
                GetBasicAlgorithmModelView algorithmModelView = AlgorithmModelViewService.fromEntityAsBasic(algorithm);
                allAlgorithmsModelView.Add(algorithmModelView);
            }

            return(allAlgorithmsModelView);
        }