/// <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); }
/// <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); }