using MediatR; using Microsoft.AspNetCore.Components.Forms; using Modules.Library.Application.Commands.CommonModels; using Modules.Library.Application.Gateways; using Modules.Media.Api.Commands; namespace Modules.Library.Application.Commands.Anime.Title.Properties.RelatedContent; public class DeleteRelatedContentCommand : IRequest { public Guid TitleId { get; set; } public MediaInfoType Type { get; set; } public string ObjectId { get; set; } = default!; public string ContentType { get; set; } = default!; } public class DeleteRelatedContentCommandHandler(IAnimeTitleGateway titleGateway, IMediator mediator) : IRequestHandler { public async Task Handle(DeleteRelatedContentCommand request, CancellationToken cancellationToken) { var title = await titleGateway.GetById(request.TitleId); var mediaInfo = new Domain.Entities.MediaInfo(request.ObjectId, (Domain.Entities.MediaInfoType)request.Type, request.ContentType); var deleted = await mediator.Send(new DeleteObjectCommand { BusketName = "my-bookmark.library", ObjectName = mediaInfo.ObjectId, }, cancellationToken); if (deleted) { title.CommonProperties.RemoveRelatedContent(mediaInfo); await titleGateway.Update(title); } return Unit.Value; } }