public async Task <IEnumerable <DefinedDatasetModel> > GetDatasetsByTypeNameAsync(string name) { var type = await _fieldTypeRepository.GetByNameAsync(name.ToLower()); if (type == null) { throw new InvalidDataException($"Can't get Type <{name}>!"); } var definedDatasets = type.Name.ToLower() != "enum" ? await _definedDatasetRepository.GetDatasetsByTypeNameAsync(name.ToLower()) : await _definedDatasetRepository.GetAllAsync(); if (definedDatasets == null) { throw new InvalidDataException($"Can't get Defined Datasets with Type <{name}> !"); } return(_mapper.Map <IEnumerable <DefinedDatasetModel> >(definedDatasets)); }
public async Task AddAsync(CustomDatasetModel customDatasetModel) { var customDataset = _mapper.Map <CustomDataset>(customDatasetModel); var dataset = _mapper.Map <Dataset>(customDatasetModel); var customDatasetValues = _mapper.Map <IEnumerable <CustomDatasetValue> >(customDatasetModel.Values).Select(item => { item.Dataset = customDataset; return(item); }).ToList(); await _customDatasetRepository.AddAsync(customDataset); await _customDatasetRepository.AddValuesAsync(customDatasetValues); dataset.Type = await _typesRepository.GetByNameAsync(Enum.GetName(typeof(SupportedTypes), SupportedTypes.String).ToLower()); await _datasetRepository.AddAsync(dataset); await _uow.CommitAsync(); }