using ECMJobRunner.Domain.Entities;
using ECMJobRunner.Domain.Interfaces;
using ECMJobRunner.Domain.ValueObjects;
using MediatR;
using System.Text.Json.Serialization;
using System.Threading;
using System.Threading.Tasks;
namespace ECMJobRunner.Application.ProfileHistories.Commands
{
///
/// Command to create a new profile execution history record
///
public class CreateProfileHistoryCommand : IRequest
{
///
/// Foreign key to the related profile
///
public long ProfileId { get; set; }
///
/// Execution result type
///
public ResultType Result { get; set; }
///
/// Result text/message
///
#if NET
public required string ResultText { get; set; }
#else
public string ResultText { get; set; } = null!;
#endif
///
/// Created by (max 50 chars)
///
[JsonIgnore]
public string AddedWho { get; set; } = null!;
}
///
/// Handler for
///
///
/// Constructor
///
public class CreateProfileHistoryCommandHandler(IProfileHistoryRepository Repository) : IRequestHandler
{
///
/// Handles the command by persisting a new record
///
public async Task Handle(CreateProfileHistoryCommand request, CancellationToken cancellationToken)
{
await Repository.AddAsync(request, cancellationToken);
return Unit.Value;
}
}
}