1
0
mirror of https://github.com/bitwarden/server.git synced 2025-07-02 00:22:50 -05:00

SelectionReadOnly MERGE to CollectionGroup

This commit is contained in:
Kyle Spearrin
2017-05-11 11:41:13 -04:00
parent f0d7dc8023
commit 2b8db4d1ed
18 changed files with 129 additions and 73 deletions

View File

@ -4,6 +4,7 @@ using Bit.Core.Exceptions;
using Bit.Core.Models.Table;
using Bit.Core.Repositories;
using System.Collections.Generic;
using Bit.Core.Models.Data;
namespace Bit.Core.Services
{
@ -20,7 +21,7 @@ namespace Bit.Core.Services
_groupRepository = groupRepository;
}
public async Task SaveAsync(Group group, IEnumerable<Guid> collectionIds = null)
public async Task SaveAsync(Group group, IEnumerable<SelectionReadOnly> collections = null)
{
var org = await _organizationRepository.GetByIdAsync(group.OrganizationId);
if(org == null)
@ -35,24 +36,24 @@ namespace Bit.Core.Services
if(group.Id == default(Guid))
{
if(collectionIds == null)
if(collections == null)
{
await _groupRepository.CreateAsync(group);
}
else
{
await _groupRepository.CreateAsync(group, collectionIds);
await _groupRepository.CreateAsync(group, collections);
}
}
else
{
if(collectionIds == null)
if(collections == null)
{
await _groupRepository.ReplaceAsync(group);
}
else
{
await _groupRepository.ReplaceAsync(group, collectionIds);
await _groupRepository.ReplaceAsync(group, collections);
}
}
}