Пример #1
0
        public async Task <FieldTypeModel> GetByIdAsync(int id)
        {
            var type = await _fieldTypeRepository.GetByIdAsync(id);

            if (type == null)
            {
                throw new InvalidDataException($"Can't get Type with id {id} !");
            }
            return(_mapper.Map <FieldTypeModel>(type));
        }
Пример #2
0
        public async Task <IEnumerable <DefinedDatasetModel> > GetDatasetsByTypeIdAsync(int id)
        {
            var type = await _fieldTypeRepository.GetByIdAsync(id);

            if (type == null)
            {
                throw new InvalidDataException($"Can't get Type with id {id}!");
            }
            var definedDatasets = type.Name.ToLower() != "enum" ? await _definedDatasetRepository.GetDatasetsByTypeIdAsync(id) : await _definedDatasetRepository.GetAllAsync();

            if (definedDatasets == null)
            {
                throw new InvalidDataException($"Can't get Defined Datasets with Type id {id} !");
            }
            return(_mapper.Map <IEnumerable <DefinedDatasetModel> >(definedDatasets));
        }