using MediatR; using MemeVault.Application.Common; using MemeVault.Domain.Aggregates.Collection; using MemeVault.Domain.Repositories; namespace MemeVault.Application.Commands.CreateCollection; public sealed class CreateCollectionCommandHandler : IRequestHandler { private readonly ICollectionRepository _collections; private readonly IUnitOfWork _uow; public CreateCollectionCommandHandler(ICollectionRepository collections, IUnitOfWork uow) { _collections = collections; _uow = uow; } public async Task Handle(CreateCollectionCommand request, CancellationToken cancellationToken) { var collection = Collection.Create(request.OwnerTelegramId, request.Name, request.Description); await _collections.AddAsync(collection, cancellationToken); await _uow.SaveChangesAsync(cancellationToken); return collection.Id; } }