using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using Microsoft.AspNetCore.Mvc;

using CommonHelpers;

namespace BookRegistry.Server {

//**************************************************************************************************
partial class GeneralApiResponse<TItem> {
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

internal GeneralApiResponse(Exception e)
: base( e )
{}

//--------------------------------------------------------------------------------------------------

// <exception cref="ArgumentNullException" />
internal GeneralApiResponse(List<TItem> list)
: this( true, HArgChecking.NN( list ) )
{}
// <exception cref="ArgumentNullException" />
internal GeneralApiResponse(List<TItem> list,string? message)
: this( true, HArgChecking.NN( list ), message )
{}
// <exception cref="ArgumentNullException" />
internal GeneralApiResponse(List<TItem> list,[HOptional] Guid status)
: this( true, HArgChecking.NN( list ), status )
{}
// <exception cref="ArgumentNullException" />
internal GeneralApiResponse(List<TItem> list,string? message,[HOptional] Guid status)
: this( true, HArgChecking.NN( list ), message, status )
{}

// <exception cref="ArgumentNullException" />
internal GeneralApiResponse(IEnumerable<TItem> items)
: this( true, HArgChecking.NN( items ) )
{}
// <exception cref="ArgumentNullException" />
internal GeneralApiResponse(IEnumerable<TItem> items,string? message)
: this( true, HArgChecking.NN( items ), message )
{}
// <exception cref="ArgumentNullException" />
internal GeneralApiResponse(IEnumerable<TItem> items,[HOptional] Guid status)
: this( true, HArgChecking.NN( items ), status )
{}
// <exception cref="ArgumentNullException" />
internal GeneralApiResponse(IEnumerable<TItem> items,string? message,[HOptional] Guid status)
: this( true, HArgChecking.NN( items ), message, status )
{}

//--------------------------------------------------------------------------------------------------

/// <exception cref="ArgumentException" />
internal GeneralApiResponse( bool success, List<TItem>? list )
: base( success ) { _Items_ = list; CheckItems_Arguments(); }

/// <exception cref="ArgumentException" />
internal GeneralApiResponse( bool success, List<TItem>? list, string? message )
: base( success, message ) { _Items_ = list; CheckItems_Arguments(); }

/// <exception cref="ArgumentException" />
internal GeneralApiResponse( bool success, List<TItem>? list, [HOptional] Guid status )
: base( success, status ) { _Items_ = list; CheckItems_Arguments(); }

/// <exception cref="ArgumentException" />
internal GeneralApiResponse( bool success, List<TItem>? list,
                             string? message, [HOptional] Guid status )
: base( success, message, status ) { _Items_ = list; CheckItems_Arguments(); }

//--------------------------------------------------------------------------------------------------

/// <exception cref="ArgumentException" />
internal GeneralApiResponse( bool success, IEnumerable<TItem>? items )
: base( success )
{
   if ( items != null )
      _Items_ = new List<TItem>( items );
   CheckItems_Arguments();
}
/// <exception cref="ArgumentException" />
internal GeneralApiResponse( bool success, IEnumerable<TItem>? items, string? message )
: base( success, message )
{
   if ( items != null )
      _Items_ = new List<TItem>( items );
   CheckItems_Arguments();
}
/// <exception cref="ArgumentException" />
internal GeneralApiResponse( bool success, IEnumerable<TItem>? items, [HOptional] Guid status )
: base( success, status )
{
   if ( items != null )
      _Items_ = new List<TItem>( items );
   CheckItems_Arguments();
}
/// <exception cref="ArgumentException" />
internal GeneralApiResponse( bool success, IEnumerable<TItem>? items,
                             string? message, [HOptional] Guid status )
: base( success, message, status )
{
   if ( items != null )
      _Items_ = new List<TItem>( items );
   CheckItems_Arguments();
}

//==================================================================================================

/// <exception cref="ArgumentException" />
/// <exception cref="InvalidOperationException" />
public static new GeneralApiResponse<TItem> CreateServerError(string errorMessage) =>
   new GeneralApiResponse<TItem>( errorMessage ){
      SpecialCategory = SpecialCategory_ServerError };

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
} // GeneralApiResponse<TItem>
//**************************************************************************************************

} // BookRegistry.Client/Server
