using MediatR;
using StorageService.Domain.AggregatesModel.FileShareAggregate;

namespace StorageService.API.Application.Commands.FileShare;

/// <summary>
/// EN: Command to create a file share link.
/// VI: Command để tạo link chia sẻ file.
/// </summary>
public record CreateFileShareCommand(
    Guid FileId,
    string UserId,
    SharePermission Permission,
    string? SharedWith = null,
    string? Password = null,
    DateTime? ExpiresAt = null,
    int? MaxDownloads = null
) : IRequest<CreateFileShareResult>;

/// <summary>
/// EN: Result of create file share operation.
/// VI: Kết quả của thao tác tạo file share.
/// </summary>
public record CreateFileShareResult(
    bool Success,
    Guid? ShareId,
    string? ShareToken,
    string? ShareUrl,
    string? Error)
{
    public static CreateFileShareResult Ok(Guid shareId, string shareToken, string shareUrl) 
        => new(true, shareId, shareToken, shareUrl, null);
    
    public static CreateFileShareResult Fail(string error) 
        => new(false, null, null, null, error);
}
