1
0
mirror of https://github.com/bitwarden/server.git synced 2025-06-27 22:26:13 -05:00
bitwarden/src/Core/Services/Implementations/CollectionService.cs
Rui Tome ff475afc2f
Refactor ICollectionService and CollectionService to remove SaveAsync method
* Removed the SaveAsync method from ICollectionService and its implementation in CollectionService.
* Updated related tests in CollectionServiceTests to reflect the removal of SaveAsync, ensuring existing functionality remains intact.
2025-06-12 14:49:38 +01:00

38 lines
1.2 KiB
C#

#nullable enable
using Bit.Core.Entities;
using Bit.Core.Exceptions;
using Bit.Core.Repositories;
namespace Bit.Core.Services;
public class CollectionService : ICollectionService
{
private readonly IEventService _eventService;
private readonly IOrganizationUserRepository _organizationUserRepository;
private readonly ICollectionRepository _collectionRepository;
public CollectionService(
IEventService eventService,
IOrganizationUserRepository organizationUserRepository,
ICollectionRepository collectionRepository)
{
_eventService = eventService;
_organizationUserRepository = organizationUserRepository;
_collectionRepository = collectionRepository;
}
public async Task DeleteUserAsync(Collection collection, Guid organizationUserId)
{
var orgUser = await _organizationUserRepository.GetByIdAsync(organizationUserId);
if (orgUser == null || orgUser.OrganizationId != collection.OrganizationId)
{
throw new NotFoundException();
}
await _collectionRepository.DeleteUserAsync(collection.Id, organizationUserId);
await _eventService.LogOrganizationUserEventAsync(orgUser, Enums.EventType.OrganizationUser_Updated);
}
}