1
0
mirror of https://github.com/bitwarden/server.git synced 2025-02-10 00:51:22 +01:00

Use null instead of empty lists

This commit is contained in:
Thomas Rittson 2021-06-30 14:26:28 +10:00
parent 216c96a02f
commit 775a52ca56
3 changed files with 10 additions and 10 deletions

View File

@ -285,7 +285,7 @@ namespace Bit.Api.Controllers
throw new UnauthorizedAccessException(); throw new UnauthorizedAccessException();
} }
var ciphers = new List<Cipher>(); List<Cipher> ciphers = null;
if (model.Ciphers.Any()) if (model.Ciphers.Any())
{ {
var existingCiphers = await _cipherRepository.GetManyByUserIdAsync(user.Id); var existingCiphers = await _cipherRepository.GetManyByUserIdAsync(user.Id);
@ -294,7 +294,7 @@ namespace Bit.Api.Controllers
.ToList(); .ToList();
} }
var folders = new List<Folder>(); List<Folder> folders = null;
if (model.Folders.Any()) if (model.Folders.Any())
{ {
var existingFolders = await _folderRepository.GetManyByUserIdAsync(user.Id); var existingFolders = await _folderRepository.GetManyByUserIdAsync(user.Id);
@ -303,7 +303,7 @@ namespace Bit.Api.Controllers
.ToList(); .ToList();
} }
var sends = new List<Send>(); List<Send> sends = null;
if (model.Sends?.Any() == true) if (model.Sends?.Any() == true)
{ {
var existingSends = await _sendRepository.GetManyByUserIdAsync(user.Id); var existingSends = await _sendRepository.GetManyByUserIdAsync(user.Id);

View File

@ -336,7 +336,7 @@ namespace Bit.Core.Repositories.SqlServer
// 3. Bulk copy into temp tables. // 3. Bulk copy into temp tables.
if (ciphers.Any()) if (ciphers?.Any() == true)
{ {
using (var bulkCopy = new SqlBulkCopy(connection, SqlBulkCopyOptions.KeepIdentity, transaction)) using (var bulkCopy = new SqlBulkCopy(connection, SqlBulkCopyOptions.KeepIdentity, transaction))
{ {
@ -346,7 +346,7 @@ namespace Bit.Core.Repositories.SqlServer
} }
} }
if (folders.Any()) if (folders?.Any() == true)
{ {
using (var bulkCopy = new SqlBulkCopy(connection, SqlBulkCopyOptions.KeepIdentity, transaction)) using (var bulkCopy = new SqlBulkCopy(connection, SqlBulkCopyOptions.KeepIdentity, transaction))
{ {
@ -356,7 +356,7 @@ namespace Bit.Core.Repositories.SqlServer
} }
} }
if (sends.Any()) if (sends?.Any() == true)
{ {
using (var bulkCopy = new SqlBulkCopy(connection, SqlBulkCopyOptions.KeepIdentity, transaction)) using (var bulkCopy = new SqlBulkCopy(connection, SqlBulkCopyOptions.KeepIdentity, transaction))
{ {
@ -370,7 +370,7 @@ namespace Bit.Core.Repositories.SqlServer
var sql = string.Empty; var sql = string.Empty;
if (ciphers.Any()) if (ciphers?.Any() == true)
{ {
sql += @" sql += @"
UPDATE UPDATE
@ -387,7 +387,7 @@ namespace Bit.Core.Repositories.SqlServer
C.[UserId] = @UserId"; C.[UserId] = @UserId";
} }
if (folders.Any()) if (folders?.Any() == true)
{ {
sql += @" sql += @"
UPDATE UPDATE
@ -403,7 +403,7 @@ namespace Bit.Core.Repositories.SqlServer
F.[UserId] = @UserId"; F.[UserId] = @UserId";
} }
if (sends.Any()) if (sends?.Any() == true)
{ {
sql += @" sql += @"
UPDATE UPDATE

View File

@ -742,7 +742,7 @@ namespace Bit.Core.Services
user.SecurityStamp = Guid.NewGuid().ToString(); user.SecurityStamp = Guid.NewGuid().ToString();
user.Key = key; user.Key = key;
user.PrivateKey = privateKey; user.PrivateKey = privateKey;
if (ciphers.Any() || folders.Any() || sends.Any()) if (ciphers?.Any() == true || folders?.Any() == true || sends?.Any() == true)
{ {
await _cipherRepository.UpdateUserKeysAndCiphersAsync(user, ciphers, folders, sends); await _cipherRepository.UpdateUserKeysAndCiphersAsync(user, ciphers, folders, sends);
} }