示例#1
0
        public async Task <ListResponseModel <CipherMiniDetailsResponseModel> > GetOrganizationCollections(
            string organizationId)
        {
            var userId    = _userService.GetProperUserId(User).Value;
            var orgIdGuid = new Guid(organizationId);

            if (!_currentContext.ManageAllCollections(orgIdGuid) && !_currentContext.AccessReports(orgIdGuid))
            {
                throw new NotFoundException();
            }

            var ciphers = await _cipherRepository.GetManyByOrganizationIdAsync(orgIdGuid);

            var collectionCiphers = await _collectionCipherRepository.GetManyByOrganizationIdAsync(orgIdGuid);

            var collectionCiphersGroupDict = collectionCiphers.GroupBy(c => c.CipherId).ToDictionary(s => s.Key);

            var responses = ciphers.Select(c => new CipherMiniDetailsResponseModel(c, _globalSettings,
                                                                                   collectionCiphersGroupDict));

            return(new ListResponseModel <CipherMiniDetailsResponseModel>(responses));
        }