27 lines
1.2 KiB
C#
27 lines
1.2 KiB
C#
using MediatR;
|
|
using Modules.Library.Application.Commands.CommonModels;
|
|
using Modules.Library.Application.Gateways;
|
|
|
|
namespace Modules.Library.Application.Commands.Anime.Title.Properties.RelatedContent;
|
|
|
|
public class EditRelatedContentCommand : IRequest<Unit>
|
|
{
|
|
public Guid TitleId { get; set; }
|
|
public MediaInfoType Type { get; set; }
|
|
public string Url { get; set; } = default!;
|
|
public string ContentType { get; set; } = default!;
|
|
public MediaInfoType? NewType { get; set; }
|
|
public string? NewUrl { get; set; }
|
|
public string? NewContentType { get; set; }
|
|
}
|
|
|
|
public class EditRelatedContentCommandHandler(IAnimeTitleGateway titleGateway) : IRequestHandler<EditRelatedContentCommand, Unit>
|
|
{
|
|
public async Task<Unit> Handle(EditRelatedContentCommand request, CancellationToken cancellationToken)
|
|
{
|
|
var title = await titleGateway.GetById(request.TitleId);
|
|
var mediaInfo = new Domain.Entities.MediaInfo(request.Url, (Domain.Entities.MediaInfoType)request.Type, request.ContentType);
|
|
title.CommonProperties.EditRelatedContent(mediaInfo, request.NewUrl, (Domain.Entities.MediaInfoType?)request.NewType, request.NewContentType);
|
|
return Unit.Value;
|
|
}
|
|
} |