using System;
using Newtonsoft.Json;
#if WASM
   using CommonHelpers.WASM;
namespace BookRegistry.Client.DB {
#else // !WASM:
   using System.Threading.Tasks; using System.Data; using System.Data.SqlClient;
   using CommonHelpers;
namespace BookRegistry.Server.DB {
#endif // !WASM

//**************************************************************************************************
/// <summary>
/// Book data correction (stored procedure)
/// </summary>
public static class UpdateBook_SP {
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
public static readonly Guid
   //Status_ = SPCommonStatuses.,
   Status_NotFound = SPCommonStatuses.NotFound,
   Status_AllreadyExists_ISBN = new Guid( "A72713DF-A0B0-409C-8139-E8F657BA4279" );
   //Status_ = new Guid( "" ),
#if SERVER
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
public const string Name = "BKRG::UpdateBook";
public static HSPCommandResult
   InvalidResult => new HSPCommandResult();
//==================================================================================================
//*
public static async Task<HSPCommandResult> EXEC_A(UpdateBook_Input input)
{
   using (new HSP(Name))
   {
      await HSP.Connect_A();
      var ( rp, cmd ) = input.BookSaving_PrepareCommand();
      HSqlParam.AddIn( cmd, "ID", input.ID );
      await HSPCommandDispose.ExecuteNonQuery_A( cmd );
      return new HSPCommandResult( rp );
   }
}
//*/
/*
public static async Task<HSPCommandResult> EXEC_A(UpdateBook_Input input)
{
   var oc = HOuterConnection.OpenTransaction();
   bool commit = true;
   using ( oc )
   { try {
   using (new HSP(Name))
   {
      await HSP.Connect_A();
      var ( rp, cmd ) = input.BookSaving_PrepareCommand();
      HSqlParam.AddIn( cmd, "ID", input.ID );
      await HSPCommandDispose.ExecuteNonQuery_A( cmd );
      return new HSPCommandResult( rp );
   } // using
   } catch {
      commit = false; throw;
   } finally {
      if (commit) await oc.CommitTransaction_A();
   }} // try
}
*/
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#endif // SERVER
} // UpdateBook_SP
//**************************************************************************************************

/// <summary>
/// Input parameters model as extension of “BookSaving_Input” (base model class)
/// </summary>
public class UpdateBook_Input: BookSaving_Input
{
// Book identifier here is required:
   [JsonProperty(Order=1)]
   public Guid ID {
      get => Value( NID );
      set => NID = value; } internal Guid? NID;
} // UpdateBook_Input

//==================================================================================================
} // BookRegistry.Client/Server.DB
