// EN: FluentValidation validators for inventory commands.
// VI: FluentValidation validators cho inventory commands.

using FluentValidation;
using InventoryService.API.Application.Commands;

namespace InventoryService.API.Application.Validations;

/// <summary>
/// EN: Validator for StockInCommand.
/// VI: Validator cho StockInCommand.
/// </summary>
public class StockInCommandValidator : AbstractValidator<StockInCommand>
{
    public StockInCommandValidator()
    {
        RuleFor(x => x.ProductId)
            .NotEmpty()
            .WithMessage("Product ID is required / Product ID bắt buộc");

        RuleFor(x => x.ShopId)
            .NotEmpty()
            .WithMessage("Shop ID is required / Shop ID bắt buộc");

        RuleFor(x => x.Amount)
            .GreaterThan(0)
            .WithMessage("Amount must be greater than 0 / Số lượng phải lớn hơn 0");
    }
}

/// <summary>
/// EN: Validator for StockOutCommand.
/// VI: Validator cho StockOutCommand.
/// </summary>
public class StockOutCommandValidator : AbstractValidator<StockOutCommand>
{
    public StockOutCommandValidator()
    {
        RuleFor(x => x.ProductId)
            .NotEmpty()
            .WithMessage("Product ID is required / Product ID bắt buộc");

        RuleFor(x => x.ShopId)
            .NotEmpty()
            .WithMessage("Shop ID is required / Shop ID bắt buộc");

        RuleFor(x => x.Amount)
            .GreaterThan(0)
            .WithMessage("Amount must be greater than 0 / Số lượng phải lớn hơn 0");
    }
}

/// <summary>
/// EN: Validator for ReserveStockCommand.
/// VI: Validator cho ReserveStockCommand.
/// </summary>
public class ReserveStockCommandValidator : AbstractValidator<ReserveStockCommand>
{
    public ReserveStockCommandValidator()
    {
        RuleFor(x => x.ProductId)
            .NotEmpty()
            .WithMessage("Product ID is required / Product ID bắt buộc");

        RuleFor(x => x.ShopId)
            .NotEmpty()
            .WithMessage("Shop ID is required / Shop ID bắt buộc");

        RuleFor(x => x.Amount)
            .GreaterThan(0)
            .WithMessage("Amount must be greater than 0 / Số lượng phải lớn hơn 0");

        RuleFor(x => x.OrderId)
            .NotEmpty()
            .WithMessage("Order ID is required / Order ID bắt buộc");
    }
}

/// <summary>
/// EN: Validator for ReleaseReservationCommand.
/// VI: Validator cho ReleaseReservationCommand.
/// </summary>
public class ReleaseReservationCommandValidator : AbstractValidator<ReleaseReservationCommand>
{
    public ReleaseReservationCommandValidator()
    {
        RuleFor(x => x.ProductId)
            .NotEmpty()
            .WithMessage("Product ID is required / Product ID bắt buộc");

        RuleFor(x => x.ShopId)
            .NotEmpty()
            .WithMessage("Shop ID is required / Shop ID bắt buộc");

        RuleFor(x => x.Amount)
            .GreaterThan(0)
            .WithMessage("Amount must be greater than 0 / Số lượng phải lớn hơn 0");

        RuleFor(x => x.OrderId)
            .NotEmpty()
            .WithMessage("Order ID is required / Order ID bắt buộc");
    }
}

/// <summary>
/// EN: Validator for AdjustStockCommand.
/// VI: Validator cho AdjustStockCommand.
/// </summary>
public class AdjustStockCommandValidator : AbstractValidator<AdjustStockCommand>
{
    public AdjustStockCommandValidator()
    {
        RuleFor(x => x.ProductId)
            .NotEmpty()
            .WithMessage("Product ID is required / Product ID bắt buộc");

        RuleFor(x => x.ShopId)
            .NotEmpty()
            .WithMessage("Shop ID is required / Shop ID bắt buộc");

        RuleFor(x => x.NewQuantity)
            .GreaterThanOrEqualTo(0)
            .WithMessage("New quantity must be >= 0 / Số lượng mới phải >= 0");

        RuleFor(x => x.Notes)
            .NotEmpty()
            .WithMessage("Notes are required for adjustment / Ghi chú bắt buộc cho điều chỉnh");
    }
}
