예제 #1
0
        public async Task Edit(string orgSlug, string dsSlug, DatasetEditDto dataset)
        {
            if (dataset == null)
            {
                throw new BadRequestException("Dataset is null");
            }

            var ds = await _utils.GetDataset(orgSlug, dsSlug);

            if (!await _authManager.IsOwnerOrAdmin(ds))
            {
                throw new UnauthorizedException("The current user is not allowed to edit dataset");
            }

            var ddb        = _ddbManager.Get(orgSlug, ds.InternalRef);
            var attributes = await ddb.GetAttributesAsync();

            if (dataset.IsPublic != null)
            {
                attributes.IsPublic = dataset.IsPublic.Value;
            }

            if (!string.IsNullOrWhiteSpace(dataset.Name))
            {
                ddb.Meta.GetSafe().Name = dataset.Name;
            }

            await _context.SaveChangesAsync();
        }
예제 #2
0
        public async Task <IActionResult> Put([FromRoute] string orgSlug, string dsSlug, [FromForm] DatasetEditDto dataset)
        {
            try
            {
                _logger.LogDebug("Dataset controller Put('{OrgSlug}', '{DsSlug}')", orgSlug, dsSlug);

                await _datasetsManager.Edit(orgSlug, dsSlug, dataset);

                return(NoContent());
            }
            catch (Exception ex)
            {
                _logger.LogError(ex, "Exception in Dataset controller Put('{OrgSlug}', '{DsSlug}')", orgSlug, dsSlug);
                return(ExceptionResult(ex));
            }
        }