1
0
mirror of https://github.com/bitwarden/server.git synced 2024-12-30 18:17:36 +01:00

renaming collection linq predicates

This commit is contained in:
Kyle Spearrin 2017-04-27 09:39:21 -04:00
parent 755da8c38f
commit 77aec3977c
9 changed files with 23 additions and 23 deletions

View File

@ -97,7 +97,7 @@ namespace Bit.Api.Controllers
var ciphers = await _cipherRepository.GetManyByUserIdHasCollectionsAsync(userId);
var collectionCiphers = await _collectionCipherRepository.GetManyByUserIdAsync(userId);
var collectionCiphersGroupDict = collectionCiphers.GroupBy(s => s.CipherId).ToDictionary(s => s.Key);
var collectionCiphersGroupDict = collectionCiphers.GroupBy(c => c.CipherId).ToDictionary(s => s.Key);
var responses = ciphers.Select(c => new CipherDetailsResponseModel(c, collectionCiphersGroupDict));
return new ListResponseModel<CipherDetailsResponseModel>(responses);
@ -116,7 +116,7 @@ namespace Bit.Api.Controllers
var ciphers = await _cipherRepository.GetManyByOrganizationIdAsync(orgIdGuid);
var collectionCiphers = await _collectionCipherRepository.GetManyByOrganizationIdAsync(orgIdGuid);
var collectionCiphersGroupDict = collectionCiphers.GroupBy(s => s.CipherId).ToDictionary(s => s.Key);
var collectionCiphersGroupDict = collectionCiphers.GroupBy(c => c.CipherId).ToDictionary(s => s.Key);
var responses = ciphers.Select(c => new CipherMiniDetailsResponseModel(c, collectionCiphersGroupDict));
return new ListResponseModel<CipherMiniDetailsResponseModel>(responses);
@ -134,7 +134,7 @@ namespace Bit.Api.Controllers
{
var userId = _userService.GetProperUserId(User).Value;
var folderCiphers = model.Folders.Select(f => f.ToFolder(userId)).ToList();
var otherCiphers = model.Logins.Select(s => s.ToCipherDetails(userId)).ToList();
var otherCiphers = model.Logins.Select(l => l.ToCipherDetails(userId)).ToList();
await _cipherService.ImportCiphersAsync(
folderCiphers,
@ -179,7 +179,7 @@ namespace Bit.Api.Controllers
}
await _cipherService.ShareAsync(model.Cipher.ToCipher(cipher), new Guid(model.Cipher.OrganizationId),
model.CollectionIds.Select(s => new Guid(s)), userId);
model.CollectionIds.Select(c => new Guid(c)), userId);
}
[HttpPut("{id}/collections")]
@ -194,7 +194,7 @@ namespace Bit.Api.Controllers
throw new NotFoundException();
}
await _cipherService.SaveCollectionsAsync(cipher, model.CollectionIds.Select(s => new Guid(s)), userId, false);
await _cipherService.SaveCollectionsAsync(cipher, model.CollectionIds.Select(c => new Guid(c)), userId, false);
}
[HttpPut("{id}/collections-admin")]
@ -209,7 +209,7 @@ namespace Bit.Api.Controllers
throw new NotFoundException();
}
await _cipherService.SaveCollectionsAsync(cipher, model.CollectionIds.Select(s => new Guid(s)), userId, true);
await _cipherService.SaveCollectionsAsync(cipher, model.CollectionIds.Select(c => new Guid(c)), userId, true);
}
[HttpDelete("{id}")]

View File

@ -43,7 +43,7 @@ namespace Bit.Api.Controllers
}
var collectionUsers = await _collectionUserRepository.GetManyDetailsByCollectionIdAsync(collectionIdGuid);
var responses = collectionUsers.Select(s => new CollectionUserResponseModel(s));
var responses = collectionUsers.Select(c => new CollectionUserResponseModel(c));
return new ListResponseModel<CollectionUserResponseModel>(responses);
}

View File

@ -54,7 +54,7 @@ namespace Bit.Api.Controllers
}
var collections = await _collectionRepository.GetManyByOrganizationIdAsync(orgIdGuid);
var responses = collections.Select(s => new CollectionResponseModel(s));
var responses = collections.Select(c => new CollectionResponseModel(c));
return new ListResponseModel<CollectionResponseModel>(responses);
}
@ -62,7 +62,7 @@ namespace Bit.Api.Controllers
public async Task<ListResponseModel<CollectionResponseModel>> GetUser()
{
var collections = await _collectionRepository.GetManyByUserIdAsync(_userService.GetProperUserId(User).Value);
var responses = collections.Select(s => new CollectionResponseModel(s));
var responses = collections.Select(c => new CollectionResponseModel(c));
return new ListResponseModel<CollectionResponseModel>(responses);
}

View File

@ -50,7 +50,7 @@ namespace Bit.Api.Controllers
var userId = _userService.GetProperUserId(User).Value;
var logins = await _cipherRepository.GetManyByTypeAndUserIdAsync(Core.Enums.CipherType.Login,
userId);
var responses = logins.Select(s => new LoginResponseModel(s)).ToList();
var responses = logins.Select(l => new LoginResponseModel(l)).ToList();
return new ListResponseModel<LoginResponseModel>(responses);
}

View File

@ -75,7 +75,7 @@ namespace Bit.Api.Controllers
var userId = _userService.GetProperUserId(User);
var result = await _organizationService.InviteUserAsync(orgGuidId, userId.Value, model.Email, model.Type.Value,
model.AccessAllCollections, model.Collections?.Select(s => s.ToCollectionUser()));
model.AccessAllCollections, model.Collections?.Select(c => c.ToCollectionUser()));
}
[HttpPut("{id}/reinvite")]
@ -132,7 +132,7 @@ namespace Bit.Api.Controllers
var userId = _userService.GetProperUserId(User);
await _organizationService.SaveUserAsync(model.ToOrganizationUser(organizationUser), userId.Value,
model.Collections?.Select(s => s.ToCollectionUser()));
model.Collections?.Select(c => c.ToCollectionUser()));
}
[HttpDelete("{id}")]

View File

@ -12,11 +12,11 @@ namespace Bit.Core.Models.Api
public IEnumerable<CollectionUser> ToCollectionUsers()
{
return Collections.Select(s => new CollectionUser
return Collections.Select(c => new CollectionUser
{
OrganizationUserId = new Guid(UserId),
CollectionId = new Guid(s.CollectionId),
ReadOnly = s.ReadOnly
CollectionId = new Guid(c.CollectionId),
ReadOnly = c.ReadOnly
});
}

View File

@ -79,7 +79,7 @@ namespace Bit.Core.Models.Api
{
if(collectionCiphers.ContainsKey(cipher.Id))
{
CollectionIds = collectionCiphers[cipher.Id].Select(s => s.CollectionId);
CollectionIds = collectionCiphers[cipher.Id].Select(c => c.CollectionId);
}
else
{
@ -91,7 +91,7 @@ namespace Bit.Core.Models.Api
string obj = "cipherDetails")
: base(cipher, obj)
{
CollectionIds = collectionCiphers.Select(s => s.CollectionId);
CollectionIds = collectionCiphers.Select(c => c.CollectionId);
}
public IEnumerable<Guid> CollectionIds { get; set; }
@ -105,7 +105,7 @@ namespace Bit.Core.Models.Api
{
if(collectionCiphers.ContainsKey(cipher.Id))
{
CollectionIds = collectionCiphers[cipher.Id].Select(s => s.CollectionId);
CollectionIds = collectionCiphers[cipher.Id].Select(c => c.CollectionId);
}
else
{

View File

@ -41,7 +41,7 @@ namespace Bit.Core.Models.Api
: base(organizationUser, "organizationUserDetails")
{
Collections = new ListResponseModel<OrganizationUserCollectionResponseModel>(
collections.Select(s => new OrganizationUserCollectionResponseModel(s)));
collections.Select(c => new OrganizationUserCollectionResponseModel(c)));
}
public ListResponseModel<OrganizationUserCollectionResponseModel> Collections { get; set; }

View File

@ -900,10 +900,10 @@ namespace Bit.Core.Services
var currentUserCollections = newUser ? null : await _collectionUserRepository.GetManyByOrganizationUserIdAsync(user.Id);
// Let's make sure all these belong to this user and organization.
var filteredCollections = collections.Where(s => orgCollections.Any(os => os.Id == s.CollectionId));
var filteredCollections = collections.Where(c => orgCollections.Any(os => os.Id == c.CollectionId));
foreach(var collection in filteredCollections)
{
var existingCollectionUser = currentUserCollections?.FirstOrDefault(cs => cs.CollectionId == collection.CollectionId);
var existingCollectionUser = currentUserCollections?.FirstOrDefault(cu => cu.CollectionId == collection.CollectionId);
if(existingCollectionUser != null)
{
collection.Id = existingCollectionUser.Id;
@ -916,8 +916,8 @@ namespace Bit.Core.Services
if(!newUser)
{
var collectionsToDelete = currentUserCollections.Where(cs =>
!filteredCollections.Any(s => s.CollectionId == cs.CollectionId));
var collectionsToDelete = currentUserCollections.Where(cu =>
!filteredCollections.Any(c => c.CollectionId == cu.CollectionId));
foreach(var collection in collectionsToDelete)
{
await _collectionUserRepository.DeleteAsync(collection);