Add rename show functionality: implement API endpoint for renaming shows, update Show model to support name changes, and enhance ShowMetadataCard UI for name input. Update translations for new UI elements to improve user experience.
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
using LiteCqrs;
|
||||
using TeleWave.Application.Common.Models;
|
||||
|
||||
namespace TeleWave.Application.Library.RenameShow;
|
||||
|
||||
/// <summary>Изменить отображаемое название шоу.</summary>
|
||||
public sealed record RenameShowCommand(Guid Id, string Name) : ICommand<Result>;
|
||||
@@ -0,0 +1,23 @@
|
||||
using LiteCqrs;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using TeleWave.Application.Common.Interfaces;
|
||||
using TeleWave.Application.Common.Models;
|
||||
|
||||
namespace TeleWave.Application.Library.RenameShow;
|
||||
|
||||
public sealed class RenameShowCommandHandler(IAppDbContext dbContext)
|
||||
: ICommandHandler<RenameShowCommand, Result>
|
||||
{
|
||||
public async Task<Result> Handle(RenameShowCommand 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.SetName(command.Name.Trim());
|
||||
return Result.Success();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
using FluentValidation;
|
||||
|
||||
namespace TeleWave.Application.Library.RenameShow;
|
||||
|
||||
public sealed class RenameShowCommandValidator : AbstractValidator<RenameShowCommand>
|
||||
{
|
||||
public RenameShowCommandValidator()
|
||||
{
|
||||
RuleFor(x => x.Name).NotEmpty().MaximumLength(256);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user