using System;
using System.Runtime.CompilerServices;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;

using CommonHelpers;

namespace BookRegistry.Server {

//**************************************************************************************************
partial class GeneralApiResponseController {
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

/// <exception cref="InvalidOperationException" />
[HAsyncStatic]
protected Task<dynamic> Do_A<TItem>( ApiArgumentsBase? args,
                                     Func<Task<GeneralApiResponse<TItem>>> bodyA,
                                     [CallerMemberName][HRequired]
                                     string? methodNameOrSignature=null )
{
   ApplyQueryArgsToContext( args );
   return DoAuto_A<GeneralApiResponse<TItem>>(
      CreateErrorResponseWithItemsCallback<TItem>(), bodyA, methodNameOrSignature );
}

/// <exception cref="InvalidOperationException" />
[HAsyncStatic]
protected Task<dynamic> DoDynamic_A<TItem>(
   ApiArgumentsBase? args, Func<Task<dynamic>> bodyA,
   [CallerMemberName][HRequired] string? methodNameOrSignature=null )
{
   ApplyQueryArgsToContext( args );
   return base.DoDynamic_A<dynamic>(
      CreateErrorResponseWithItemsCallback<TItem>(), bodyA, methodNameOrSignature );
}

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

/// <exception cref="InvalidOperationException" />
[HAsyncStatic]
protected Task<ActionResult<GeneralApiResponse<TItem>>> DoExplicit_A<TItem>(
   ApiArgumentsBase? args,
   Func<Task<ActionResult<GeneralApiResponse<TItem>>>> bodyA,
   [CallerMemberName][HRequired] string? methodNameOrSignature=null )
{
   ApplyQueryArgsToContext( args );
   return base.DoExplicit_A<GeneralApiResponse<TItem>>(
      CreateErrorResponseWithItemsCallback<TItem>(), bodyA, methodNameOrSignature );
}

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

/// <exception cref="InvalidOperationException" />
[HAsyncStatic]
protected Task<dynamic> Do_A<TItem>( string methodNameOrSignature,
                                     ApiArgumentsBase? args,
                                     Func<Task<GeneralApiResponse<TItem>>> bodyA )
{
   ApplyQueryArgsToContext( args );
   return DoAuto_A<GeneralApiResponse<TItem>>(
      methodNameOrSignature, CreateErrorResponseWithItemsCallback<TItem>(), bodyA );
}

/// <exception cref="InvalidOperationException" />
[HAsyncStatic]
protected Task<dynamic> DoDynamic_A<TItem>( string methodNameOrSignature,
                                            ApiArgumentsBase? args,
                                            Func<Task<dynamic>> bodyA )
{
   ApplyQueryArgsToContext( args );
   return base.DoDynamic_A<dynamic>(
      methodNameOrSignature, CreateErrorResponseWithItemsCallback<TItem>(), bodyA );
}

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

/// <exception cref="InvalidOperationException" />
[HAsyncStatic]
protected Task<ActionResult<GeneralApiResponse<TItem>>> DoExplicit_A<TItem>(
   string methodNameOrSignature,
   ApiArgumentsBase? args,
   Func<Task<ActionResult<GeneralApiResponse<TItem>>>> bodyA )
{
   ApplyQueryArgsToContext( args );
   return base.DoExplicit_A<GeneralApiResponse<TItem>>(
      methodNameOrSignature, CreateErrorResponseWithItemsCallback<TItem>(), bodyA );
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
} // GeneralApiResponseController
//**************************************************************************************************

} // BookRegistry.Server
