using MediatR; using Microsoft.AspNetCore.Components.Forms; using Modules.Library.Application.Gateways; using Modules.Media.Api.Commands; namespace Modules.Library.Application.Commands.Anime.Title.Properties.Preview; public class DeletePreviewCommand : IRequest { public Guid TitleId { get; set; } } public class DeletePreviewCommandHandler(IAnimeTitleGateway titleGateway, IMediator mediator) : IRequestHandler { public async Task Handle(DeletePreviewCommand request, CancellationToken cancellationToken) { var title = await titleGateway.GetById(request.TitleId); var objectId = title.CommonProperties.Preview?.ObjectId; if (!string.IsNullOrWhiteSpace(objectId)) { var deleted = await mediator.Send(new DeleteObjectCommand { BusketName = "my-bookmark.library", ObjectName = objectId, }, cancellationToken); if (deleted) { title.CommonProperties.DeletePreview(); await titleGateway.Update(title); } } return Unit.Value; } }