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

using CommonHelpers;

namespace BookRegistry.Server {

//**************************************************************************************************
partial class GeneralApiResponseController: XControllerBase {
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

/// <exception cref="InvalidOperationException" />
[HAsyncStatic]
protected dynamic Do( ApiArgumentsBase? args,
                      Func<GeneralApiResponse> body,
                      [CallerMemberName][HRequired] string? methodNameOrSignature=null )
{
   ApplyQueryArgsToContext( args );
   return DoAuto<GeneralApiResponse>( CreateErrorResponseCallback, body, methodNameOrSignature );
}

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

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

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

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

/// <exception cref="InvalidOperationException" />
[HAsyncStatic]
protected dynamic Do( string methodNameOrSignature,
                      ApiArgumentsBase? args, Func<GeneralApiResponse> body )
{
   ApplyQueryArgsToContext( args );
   return DoAuto<GeneralApiResponse>( methodNameOrSignature, CreateErrorResponseCallback, body );
}

/// <exception cref="InvalidOperationException" />
[HAsyncStatic]
protected dynamic DoDynamic( string methodNameOrSignature,
                             ApiArgumentsBase? args, Func<dynamic> body )
{
   ApplyQueryArgsToContext( args );
   return base.DoDynamic<dynamic>( methodNameOrSignature, CreateErrorResponseCallback, body );
}

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

/// <exception cref="InvalidOperationException" />
[HAsyncStatic]
protected ActionResult<GeneralApiResponse> DoExplicit(
   string methodNameOrSignature,
   ApiArgumentsBase? args, Func<ActionResult<GeneralApiResponse>> body )
{
   ApplyQueryArgsToContext( args );
   return base.DoExplicit<GeneralApiResponse>(
      methodNameOrSignature, CreateErrorResponseCallback, body );
}

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

} // BookRegistry.Server
