too many changes

This commit is contained in:
2026-10-07 02:17:30 +04:00
parent 0c7f3bce90
commit bcf985c17d
74 changed files with 4048 additions and 78 deletions
@@ -0,0 +1,33 @@
using MediatR;
using MemeVault.Application.Common;
using MemeVault.Domain.Enums;
using MemeVault.Domain.Exceptions;
using MemeVault.Domain.Repositories;
namespace MemeVault.Application.Commands.SetCollectionInbox;
public sealed class SetCollectionInboxCommandHandler(
ICollectionRepository collections,
IUnitOfWork unitOfWork)
: IRequestHandler<SetCollectionInboxCommand, bool>
{
public async Task<bool> Handle(SetCollectionInboxCommand request, CancellationToken ct)
{
var target = await collections.GetByIdAsync(request.CollectionId, ct);
if (target is null || target.GetRole(request.RequestingTelegramId) != CollectionRole.Owner)
return false;
if (target.IsInbox)
throw new DomainException("Collection is already the Inbox.");
// Снимаем флаг с текущего Inbox
var currentInbox = await collections.GetInboxAsync(request.RequestingTelegramId, ct);
currentInbox?.DemoteFromInbox();
// Промоция целевой коллекции
target.PromoteToInbox(request.RequestingTelegramId);
await unitOfWork.SaveChangesAsync(ct);
return true;
}
}