diff --git a/src/Core/Vault/Services/Implementations/CipherService.cs b/src/Core/Vault/Services/Implementations/CipherService.cs index 3a970d82bdff..602145cb9906 100644 --- a/src/Core/Vault/Services/Implementations/CipherService.cs +++ b/src/Core/Vault/Services/Implementations/CipherService.cs @@ -233,7 +233,14 @@ await _cipherRepository.UpdateAttachmentAsync(new CipherAttachment // Update the revision date when an attachment is added cipher.RevisionDate = DateTime.UtcNow; - await _cipherRepository.ReplaceAsync((CipherDetails)cipher); + if (cipher is CipherDetails cipherDetails) + { + await _cipherRepository.ReplaceAsync(cipherDetails); + } + else + { + await _cipherRepository.ReplaceAsync(cipher); + } await _pushService.PushSyncCipherUpdateAsync(cipher, null); @@ -287,7 +294,14 @@ public async Task CreateAttachmentAsync(Cipher cipher, Stream stream, string fil // Update the revision date when an attachment is added cipher.RevisionDate = DateTime.UtcNow; - await _cipherRepository.ReplaceAsync((CipherDetails)cipher); + if (cipher is CipherDetails cipherDetails) + { + await _cipherRepository.ReplaceAsync(cipherDetails); + } + else + { + await _cipherRepository.ReplaceAsync(cipher); + } // push await _pushService.PushSyncCipherUpdateAsync(cipher, null); @@ -898,9 +912,13 @@ private async Task DeleteAttachmentAsync(Cipher ci { await _cipherRepository.ReplaceAsync(cipher); } + else if (cipher is CipherDetails cipherDetails) + { + await _cipherRepository.ReplaceAsync(cipherDetails); + } else { - await _cipherRepository.ReplaceAsync((CipherDetails)cipher); + await _cipherRepository.ReplaceAsync(cipher); } // push