// EN: DTOs for Inventory Service API.
// VI: DTOs cho Inventory Service API.

namespace InventoryService.API.Application.DTOs;

/// <summary>
/// EN: DTO for inventory item.
/// VI: DTO cho inventory item.
/// </summary>
public record InventoryItemDto(
    Guid Id,
    Guid ProductId,
    Guid ShopId,
    int Quantity,
    int ReservedQuantity,
    int AvailableQuantity,
    int ReorderLevel,
    DateTime? UpdatedAt);

/// <summary>
/// EN: DTO for inventory transaction.
/// VI: DTO cho inventory transaction.
/// </summary>
public record InventoryTransactionDto(
    Guid Id,
    Guid InventoryItemId,
    string TransactionType,
    int Quantity,
    Guid? ReferenceId,
    string? Notes,
    DateTime CreatedAt);

/// <summary>
/// EN: Request for stock in operation.
/// VI: Request cho thao tác nhập kho.
/// </summary>
public record StockInRequest(
    Guid ProductId,
    Guid ShopId,
    int Amount,
    string? Notes,
    Guid? ReferenceId);

/// <summary>
/// EN: Request for stock out operation.
/// VI: Request cho thao tác xuất kho.
/// </summary>
public record StockOutRequest(
    Guid ProductId,
    Guid ShopId,
    int Amount,
    string? Notes,
    Guid? ReferenceId);

/// <summary>
/// EN: Request for stock reservation.
/// VI: Request cho đặt trước stock.
/// </summary>
public record ReserveStockRequest(
    Guid ProductId,
    Guid ShopId,
    int Amount,
    Guid OrderId);

/// <summary>
/// EN: Request for releasing reservation.
/// VI: Request cho giải phóng đặt trước.
/// </summary>
public record ReleaseReservationRequest(
    Guid ProductId,
    Guid ShopId,
    int Amount,
    Guid OrderId);

/// <summary>
/// EN: Request for stock adjustment.
/// VI: Request cho điều chỉnh stock.
/// </summary>
public record AdjustStockRequest(
    Guid ProductId,
    Guid ShopId,
    int NewQuantity,
    string Notes);

/// <summary>
/// EN: Standard API response wrapper.
/// VI: Wrapper response API chuẩn.
/// </summary>
public class ApiResponse<T>
{
    public bool Success { get; set; }
    public T? Data { get; set; }
    public string? Error { get; set; }

    public static ApiResponse<T> Ok(T data) => new() { Success = true, Data = data };
    public static ApiResponse<T> Fail(string error) => new() { Success = false, Error = error };
}

/// <summary>
/// EN: Paged result for queries.
/// VI: Kết quả phân trang cho queries.
/// </summary>
public record PagedResult<T>(
    IReadOnlyList<T> Items,
    int TotalCount);
