1
0
mirror of https://github.com/bitwarden/server.git synced 2025-02-03 23:51:21 +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();
}
var ciphers = new List<Cipher>();
List<Cipher> ciphers = null;
if (model.Ciphers.Any())
{
var existingCiphers = await _cipherRepository.GetManyByUserIdAsync(user.Id);
@ -294,7 +294,7 @@ namespace Bit.Api.Controllers
.ToList();
}
var folders = new List<Folder>();
List<Folder> folders = null;
if (model.Folders.Any())
{
var existingFolders = await _folderRepository.GetManyByUserIdAsync(user.Id);
@ -303,7 +303,7 @@ namespace Bit.Api.Controllers
.ToList();
}
var sends = new List<Send>();
List<Send> sends = null;
if (model.Sends?.Any() == true)
{
var existingSends = await _sendRepository.GetManyByUserIdAsync(user.Id);

View File

@ -336,7 +336,7 @@ namespace Bit.Core.Repositories.SqlServer
// 3. Bulk copy into temp tables.
if (ciphers.Any())
if (ciphers?.Any() == true)
{
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))
{
@ -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))
{
@ -370,7 +370,7 @@ namespace Bit.Core.Repositories.SqlServer
var sql = string.Empty;
if (ciphers.Any())
if (ciphers?.Any() == true)
{
sql += @"
UPDATE
@ -387,7 +387,7 @@ namespace Bit.Core.Repositories.SqlServer
C.[UserId] = @UserId";
}
if (folders.Any())
if (folders?.Any() == true)
{
sql += @"
UPDATE
@ -403,7 +403,7 @@ namespace Bit.Core.Repositories.SqlServer
F.[UserId] = @UserId";
}
if (sends.Any())
if (sends?.Any() == true)
{
sql += @"
UPDATE

View File

@ -742,7 +742,7 @@ namespace Bit.Core.Services
user.SecurityStamp = Guid.NewGuid().ToString();
user.Key = key;
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);
}