Пример #1
0
        // Method to add tags based on the id and a bit messy because it is sent as a string.
        public async Task <DatasetResponse> SaveAsync(Dataset dataset)
        {
            try
            {
                (Boolean success, String error)check = await idChecks(dataset);

                if (!check.success)
                {
                    return(new DatasetResponse(check.error));
                }
                // Sets the date and time for the attributes published and last updated to current time.
                dataset.DatePublished   = DateTime.Now;
                dataset.DateLastUpdated = DateTime.Now;

                var createDatasetTask = Task.Run(async() => {
                    dataset = await _datasetRepository.AddAsync(dataset);
                    await addTags(dataset);
                    dataset.Identifier = (Startup.Configuration != null ? Startup.Configuration["identifierUrl"] : "http://www.test.no/") + dataset.Id;
                    _datasetRepository.Update(dataset);
                    await _unitOfWork.CompleteAsync();
                    return(dataset);
                });

                return(await CreateGitLabProject(createDatasetTask, dataset));
            }
            catch (Exception ex)
            {
                // Do some logging stuff
                return(new DatasetResponse($"An error occurred when saving the dataset: {ex.Message}"));
            }
        }