Exemple #1
0
        public async Task <CollectionResponseModel> Put(string orgId, string id, [FromBody] CollectionRequestModel model)
        {
            var collection = await GetCollectionAsync(new Guid(id), new Guid(orgId));

            await _collectionService.SaveAsync(model.ToCollection(collection),
                                               model.Groups?.Select(g => g.ToSelectionReadOnly()));

            return(new CollectionResponseModel(collection));
        }
Exemple #2
0
        public async Task <CollectionResponseModel> Put(string orgId, string id, [FromBody] CollectionRequestModel model)
        {
            var collection = await _collectionRepository.GetByIdAsync(new Guid(id));

            if (collection == null || !_currentContext.OrganizationAdmin(collection.OrganizationId))
            {
                throw new NotFoundException();
            }

            await _collectionService.SaveAsync(model.ToCollection(collection));

            return(new CollectionResponseModel(collection));
        }
        public async Task <CollectionResponseModel> Post(string orgId, [FromBody] CollectionRequestModel model)
        {
            var orgIdGuid = new Guid(orgId);

            if (!_currentContext.OrganizationAdmin(orgIdGuid))
            {
                throw new NotFoundException();
            }

            var collection = model.ToCollection(orgIdGuid);
            await _collectionService.SaveAsync(collection, model.Groups?.Select(g => g.ToSelectionReadOnly()));

            return(new CollectionResponseModel(collection));
        }
Exemple #4
0
        public async Task <CollectionResponseModel> Put(Guid orgId, Guid id, [FromBody] CollectionRequestModel model)
        {
            if (!await CanEditCollectionAsync(orgId, id))
            {
                throw new NotFoundException();
            }

            var collection = await GetCollectionAsync(id, orgId);

            await _collectionService.SaveAsync(model.ToCollection(collection),
                                               model.Groups?.Select(g => g.ToSelectionReadOnly()));

            return(new CollectionResponseModel(collection));
        }
Exemple #5
0
        public async Task <CollectionResponseModel> Post(string orgId, [FromBody] CollectionRequestModel model)
        {
            var orgIdGuid = new Guid(orgId);

            if (!await ManageAnyCollections(orgIdGuid))
            {
                throw new NotFoundException();
            }

            var collection = model.ToCollection(orgIdGuid);
            await _collectionService.SaveAsync(collection, model.Groups?.Select(g => g.ToSelectionReadOnly()),
                                               !await _currentContext.ManageAllCollections(orgIdGuid)?_currentContext.UserId : null);

            return(new CollectionResponseModel(collection));
        }
Exemple #6
0
        public async Task <CollectionResponseModel> Post(Guid orgId, [FromBody] CollectionRequestModel model)
        {
            var collection = model.ToCollection(orgId);

            if (!await CanCreateCollection(orgId, collection.Id) &&
                !await CanEditCollectionAsync(orgId, collection.Id))
            {
                throw new NotFoundException();
            }

            var assignUserToCollection = !(await _currentContext.EditAnyCollection(orgId)) &&
                                         await _currentContext.EditAssignedCollections(orgId);

            await _collectionService.SaveAsync(collection, model.Groups?.Select(g => g.ToSelectionReadOnly()),
                                               assignUserToCollection?_currentContext.UserId : null);

            return(new CollectionResponseModel(collection));
        }