Esempio n. 1
0
        public async Task <IActionResult> Post([FromForm] DatasetModel model)
        {
            var data = await model.File.ReadAsListAsync();

            await _datasetRepository.AddDatasetAsync(model.Name, data);

            return(Ok());
        }
Esempio n. 2
0
        /// <summary>
        /// Create dataset
        /// </summary>
        /// <param name="datasetCreation"></param>
        /// <returns>Created dataset id</returns>
        public async Task <int> CreateAsync(DatasetCreation datasetCreation)
        {
            var userId = await GetUserIdAsync();

            var entity = _mapper.MapCreation(datasetCreation);

            await InvokeGuard(() => _guard.AgainstInvalidDatasetCreationAsync(userId, datasetCreation));

            await _repository.AddDatasetAsync(userId, entity);

            await _unitOfWork.SaveChangesAsync();

            return(entity.Id);
        }
Esempio n. 3
0
        public async Task <IActionResult> CreateDatasetAsync(DatasetInputModel model)
        {
            if (string.IsNullOrEmpty(model.Name))
            {
                return(BadRequest(ResponseResult.Failed(ErrorCode.ValidationError, "Dataset name can't be empty.")));
            }

            var dataset = Dataset.New(model.Name);

            await _datasetRepository.AddDatasetAsync(dataset);

            var result = Mapper.Map <DatasetOutputModel>(dataset);

            return(Ok(ResponseResult.SucceededWithData(result)));
        }