using System;
using Newtonsoft.Json;
#if WASM
   using CommonHelpers.WASM;
namespace BookRegistry.Client.DB {
#else // !WASM:
   using System.Data; using System.Data.SqlClient;
   using CommonHelpers;
namespace BookRegistry.Server.DB {
#endif // !WASM
//==================================================================================================
/// <summary>
/// Simple ID+Name item
/// </summary>
public class IdName_Item: ResultSetItemBase,IIdNameItemView
{
   [JsonProperty(Order=Int32.MinValue)]
   public Guid ID {
      get => Value( NID );
      set => NID = value; } internal Guid? NID = _GUID();

   [JsonProperty(Order=Int32.MinValue+1)]
   public string Name {
      get => Get( NName );
      set => NName = value; } internal string? NName = _NS();

   public override string ToString() => Name;
   public IdName_Item IdName_DuplicateItem() =>
      (IdName_Item)MemberwiseClone();
} // IdName_Item
//--------------------------------------------------------------------------------------------------

public class BookAuthor_Item: IdName_Item
{
   public BookAuthor_Item BookAuthor_DuplicateItem() =>
      (BookAuthor_Item)MemberwiseClone();
} // BookAuthor_Item

public class BookCategory_Item: IdName_Item
{
   public BookCategory_Item BookCategory_DuplicateItem() =>
      (BookCategory_Item)MemberwiseClone();
} // BookCategory_Item

public class LiteratureGenre_Item: IdName_Item
{
   [JsonProperty(Order=Int32.MinValue+2)]
   public Guid CategoryId {
      get => Value( NCategoryId );
      set => NCategoryId = value; } internal Guid? NCategoryId = _GUID();

   public LiteratureGenre_Item LiteratureGenre_DuplicateItem() =>
      (LiteratureGenre_Item)MemberwiseClone();
} // LiteratureGenre_Item

public class BookPublisher_Item: IdName_Item
{
   public BookPublisher_Item BookPublisher_DuplicateItem() =>
      (BookPublisher_Item)MemberwiseClone();
} // BookPublisher_Item

public class BookSeries_Item: IdName_Item
{
   [JsonProperty(Order=Int32.MinValue+2)]
   public int? BookCount { get; set; } = INT_N();

   public BookSeries_Item BookSeries_DuplicateItem() =>
      (BookSeries_Item)MemberwiseClone();
} // BookSeries_Item
/*
/// <summary>
/// 
/// </summary>
public class _Item: IdName_Item
{
   public _Item _DuplicateItem() =>
      (_Item)MemberwiseClone();
} // _Item
*/
//--------------------------------------------------------------------------------------------------

/// <summary>
/// Input parameters model (base for “AddBook_Input” and “UpdateBook_Input”)
/// </summary>
public class BookSaving_Input: ApiArgumentsBase
{
   public string? ISBN { get; set; }
   public string? Name { get; set; }

   public int? ReleaseYear { get; set; }

   public string? Description { get; set; }

   public Guid AuthorId {
      get => Value( NAuthorId );
      set => NAuthorId = value; } internal Guid? NAuthorId;

   public Guid PublisherId {
      get => Value( NPublisherId );
      set => NPublisherId = value; } internal Guid? NPublisherId;

   public Guid SeriesId {
      get => Value( NSeriesId );
      set => NSeriesId = value; } internal Guid? NSeriesId;

   public Guid CategoryId {
      get => Value( NCategoryId );
      set => NCategoryId = value; } internal Guid? NCategoryId;

   public Guid GenreId {
      get => Value( NGenreId );
      set => NGenreId = value; } internal Guid? NGenreId;

#if SERVER
   internal ( HSPResultParameters, SqlCommand ) BookSaving_PrepareCommand() =>
      HSP.PrepareCommand(
         HSqlParam.NullableIn( nameof(ISBN), ISBN ),
         HSqlParam.NullableIn( nameof(Name), Name ),
         HSqlParam.NullableIn( nameof(ReleaseYear), ReleaseYear ),
         HSqlParam.NullableIn( nameof(Description), Description ),
         HSqlParam.In( nameof(AuthorId), AuthorId ),
         HSqlParam.In( nameof(PublisherId), PublisherId ),
         HSqlParam.In( nameof(SeriesId), SeriesId ),
         HSqlParam.In( nameof(CategoryId), CategoryId ),
         HSqlParam.In( nameof(GenreId), GenreId ) );
#endif // SERVER
} // BookSaving_Input

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