public async Task PutRestoreMany([FromBody] CipherBulkRestoreRequestModel model) { if (!_globalSettings.SelfHosted && model.Ids.Count() > 500) { throw new BadRequestException("You can only restore up to 500 items at a time."); } var userId = _userService.GetProperUserId(User).Value; await _cipherService.RestoreManyAsync(model.Ids.Select(i => new Guid(i)), userId); }
public async Task <ListResponseModel <CipherResponseModel> > PutRestoreMany([FromBody] CipherBulkRestoreRequestModel model) { if (!_globalSettings.SelfHosted && model.Ids.Count() > 500) { throw new BadRequestException("You can only restore up to 500 items at a time."); } var userId = _userService.GetProperUserId(User).Value; var cipherIdsToRestore = new HashSet <Guid>(model.Ids.Select(i => new Guid(i))); var ciphers = await _cipherRepository.GetManyByUserIdAsync(userId); var restoringCiphers = ciphers.Where(c => cipherIdsToRestore.Contains(c.Id) && c.Edit); await _cipherService.RestoreManyAsync(restoringCiphers, userId); var responses = restoringCiphers.Select(c => new CipherResponseModel(c, _globalSettings)); return(new ListResponseModel <CipherResponseModel>(responses)); }