using System;
using System.Collections.Generic;
#if WASM
   using CommonHelpers.WASM;
namespace BookRegistry.Client.DB {
#else // !WASM:
   using System.Threading.Tasks;
   using CommonHelpers;
namespace BookRegistry.Server.DB {
#endif // !WASM

//**************************************************************************************************
/// <summary>
/// Book selection collections obtainment — 5 lists (stored procedure)
/// </summary>
/// <remarks>
/// Authors (#1), Categories (#2), Genres (#3), Publishers (#4), Series (#5)
/// </remarks>
public static class GetBookSelectionCollections_SP {
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/*
public static readonly Guid
   //Status_ = SPCommonStatuses.,
   //Status_ = new Guid( "" ),
*/
#if SERVER
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
public const string Name = "BKRG::GetBookSelectionCollections";
public static HSPResult_5<BookAuthor_Item,BookCategory_Item,LiteratureGenre_Item,BookPublisher_Item,BookSeries_Item>
   InvalidResult => new HSPResult_5<BookAuthor_Item,BookCategory_Item,LiteratureGenre_Item,BookPublisher_Item,BookSeries_Item>();
//==================================================================================================

public static async Task<HSPResult_5< BookAuthor_Item, BookCategory_Item, LiteratureGenre_Item,
                                      BookPublisher_Item, BookSeries_Item >>
   EXEC_A()
{
   using (new HSP(Name))
   {
      await HSP.Connect_A();
      var ( rp, cmd ) = HSP.PrepareCommand();
      List<BookAuthor_Item>?      list_1 = null;
      List<BookCategory_Item>?    list_2 = null;
      List<LiteratureGenre_Item>? list_3 = null;
      List<BookPublisher_Item>?   list_4 = null;
      List<BookSeries_Item>?      list_5 = null;
      using (var rdr = await HSPCommandDispose.ExecuteReader_A( cmd ))
      if ( HSP.Success( rp ) )
      {
         list_1 = await HSP.RSetToList_A<BookAuthor_Item>( 1, rdr );

         if ( !rdr.NextResult() )
            throw HDBExceptionsSPAuto.SecondResultSetWasExpected;
         list_2 = await HSP.RSetToList_A<BookCategory_Item>( 2, rdr );

         if ( !rdr.NextResult() )
            throw HDBExceptionsSPAuto.ThirdResultSetWasExpected;
         list_3 = await HSP.RSetToList_A<LiteratureGenre_Item>( 3, rdr );

         if ( !rdr.NextResult() )
            throw HDBExceptionsSPAuto.FourthResultSetWasExpected;
         list_4 = await HSP.RSetToList_A<BookPublisher_Item>( 4, rdr );

         if ( !rdr.NextResult() )
            throw HDBExceptionsSPAuto.FifthResultSetWasExpected;
         list_5 = await HSP.RSetToList_A<BookSeries_Item>( 5, rdr );
      }
      return new HSPResult_5<BookAuthor_Item,BookCategory_Item,LiteratureGenre_Item,BookPublisher_Item,BookSeries_Item>(
         rp, list_1, list_2, list_3, list_4, list_5 );
   }
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#endif // SERVER
} // GetBookSelectionCollections_SP
//**************************************************************************************************

} // BookRegistry.Client/Server.DB
