using Hutopy.Application.Common.Interfaces; namespace Hutopy.Application.TodoItems.Commands.UpdateTodoItem; public record UpdateTodoItemCommand : IRequest { public int Id { get; init; } public string? Title { get; init; } public bool Done { get; init; } } public class UpdateTodoItemCommandHandler( IApplicationDbContext context) : IRequestHandler { public async Task Handle(UpdateTodoItemCommand request, CancellationToken cancellationToken) { var entity = await context.TodoItems .FindAsync(new object[] { request.Id }, cancellationToken); Guard.Against.NotFound(request.Id, entity); entity.Title = request.Title; entity.Done = request.Done; await context.SaveChangesAsync(cancellationToken); } }