Add original name support for shows: implement API endpoint to set original name, update Show and ShowDto models to include original name field, and enhance UI components for managing original names in show metadata. Update validation and database schema accordingly.
This commit is contained in:
@@ -4,5 +4,9 @@ using TeleWave.Domain.Library;
|
||||
|
||||
namespace TeleWave.Application.Library.CreateShow;
|
||||
|
||||
public sealed record CreateShowCommand(string Name, ShowKind Kind, string? Description)
|
||||
: ICommand<Result<Guid>>;
|
||||
public sealed record CreateShowCommand(
|
||||
string Name,
|
||||
ShowKind Kind,
|
||||
string? Description,
|
||||
string? OriginalName = null
|
||||
) : ICommand<Result<Guid>>;
|
||||
|
||||
@@ -10,7 +10,7 @@ public sealed class CreateShowCommandHandler(IAppDbContext dbContext)
|
||||
{
|
||||
public Task<Result<Guid>> Handle(CreateShowCommand command, CancellationToken cancellationToken)
|
||||
{
|
||||
var show = Show.Create(command.Name, command.Kind, command.Description);
|
||||
var show = Show.Create(command.Name, command.Kind, command.Description, command.OriginalName);
|
||||
dbContext.Shows.Add(show);
|
||||
return Task.FromResult(Result.Success(show.Id));
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ public sealed class CreateShowCommandValidator : AbstractValidator<CreateShowCom
|
||||
public CreateShowCommandValidator()
|
||||
{
|
||||
RuleFor(x => x.Name).NotEmpty().MaximumLength(256);
|
||||
RuleFor(x => x.OriginalName).MaximumLength(256);
|
||||
RuleFor(x => x.Description).MaximumLength(2048);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,6 +54,7 @@ public sealed class GetShowQueryHandler(IAppDbContext dbContext)
|
||||
new ShowDto(
|
||||
show.Id,
|
||||
show.Name,
|
||||
show.OriginalName,
|
||||
show.Kind,
|
||||
show.Description,
|
||||
show.MetadataProvider,
|
||||
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
using LiteCqrs;
|
||||
using TeleWave.Application.Common.Models;
|
||||
|
||||
namespace TeleWave.Application.Library.SetShowOriginalName;
|
||||
|
||||
/// <summary>Задать/снять оригинальное название шоу (по нему ищутся метаданные).</summary>
|
||||
public sealed record SetShowOriginalNameCommand(Guid Id, string? OriginalName) : ICommand<Result>;
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
using LiteCqrs;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using TeleWave.Application.Common.Interfaces;
|
||||
using TeleWave.Application.Common.Models;
|
||||
|
||||
namespace TeleWave.Application.Library.SetShowOriginalName;
|
||||
|
||||
public sealed class SetShowOriginalNameCommandHandler(IAppDbContext dbContext)
|
||||
: ICommandHandler<SetShowOriginalNameCommand, Result>
|
||||
{
|
||||
public async Task<Result> Handle(
|
||||
SetShowOriginalNameCommand command,
|
||||
CancellationToken cancellationToken
|
||||
)
|
||||
{
|
||||
var show = await dbContext.Shows.FirstOrDefaultAsync(
|
||||
s => s.Id == command.Id,
|
||||
cancellationToken
|
||||
);
|
||||
if (show is null)
|
||||
return Result.Failure(ShowErrors.NotFound);
|
||||
|
||||
show.SetOriginalName(command.OriginalName);
|
||||
return Result.Success();
|
||||
}
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
using FluentValidation;
|
||||
|
||||
namespace TeleWave.Application.Library.SetShowOriginalName;
|
||||
|
||||
public sealed class SetShowOriginalNameCommandValidator
|
||||
: AbstractValidator<SetShowOriginalNameCommand>
|
||||
{
|
||||
public SetShowOriginalNameCommandValidator()
|
||||
{
|
||||
RuleFor(x => x.OriginalName).MaximumLength(256);
|
||||
}
|
||||
}
|
||||
@@ -32,6 +32,7 @@ public sealed record EpisodeDto(
|
||||
public sealed record ShowDto(
|
||||
Guid Id,
|
||||
string Name,
|
||||
string? OriginalName,
|
||||
ShowKind Kind,
|
||||
string? Description,
|
||||
string? MetadataProvider,
|
||||
|
||||
Reference in New Issue
Block a user