public static BaseHelper TransactionsLoanBookList(Model.TransactionsLoanBookList data)
        {
            var retVal      = new BaseHelper();
            var objJSONPage = new Output.TransactionsLoanBookList();

            try
            {
                var entityPage = TransactionsLoanBook.TransactionsLoanBookList(data, objJSONPage);
                if (objJSONPage.ResultCode == 1)
                {
                    retVal.SQLElapsed += entityPage.SQLElapsed;
                    retVal.SQLInfo($"sp : {entityPage.SQLDetail}, elapsed : {entityPage.SQLElapsed}");

                    retVal.IsError = (entityPage.ResultCode == 1) ? false : true;
                }
                else
                {
                    objJSONPage.ResultCode   = objJSONPage.ResultCode;
                    objJSONPage.ErrorMessage = objJSONPage.ErrorMessage;
                }
            }
            catch (Exception ex)
            {
                retVal.Exception = ex;

                if (ex is System.Data.SqlClient.SqlException sqlEx)
                {
                    retVal.SQLInfo($"sp:{sqlEx.Procedure}, line:{sqlEx.LineNumber}, detail:{data.SqlDetail}");
                    retVal.SQLException = true;

                    objJSONPage.ResultCode   = 69998;
                    objJSONPage.ErrorMessage = "SQL Exception";
                }
                else
                {
                    objJSONPage.ResultCode   = 69999;
                    objJSONPage.ErrorMessage = "Unknown Error";
                }
            }
            finally
            {
                retVal.SerializeObject <Output.TransactionsLoanBookList>(objJSONPage);
            }

            return(retVal);
        }
        public static BasicEntity TransactionsLoanBookList(Model.TransactionsLoanBookList data, Output.TransactionsLoanBookList obj)
        {
            var retVal = new BasicEntity();

            retVal.AddParameter("@page", data.Page);
            retVal.AddParameter("@page_size", data.PageSize);
            retVal.AddParameter("@level", data.Level);
            retVal.AddParameter("@userlogin", data.UserLogin);

            data.SqlDetail = retVal.SQLCommandBuilder("spTransactionsLoanBookList");

            using (SqlDataReader reader = retVal.ExecReader())
            {
                while (reader.Read())
                {
                    obj.ResultCode    = (reader.IsDBNull(0)) ? 0 : reader.GetInt32(0);
                    obj.ErrorMessage  = (reader.IsDBNull(1)) ? string.Empty : reader.GetString(1);
                    retVal.ResultCode = obj.ResultCode;
                }

                if (retVal.ResultCode == 1)
                {
                    reader.NextResult();
                    while (reader.Read())
                    {
                        obj.Content.TotalRows = (reader.IsDBNull(0)) ? 0 : reader.GetInt32(0);
                    }

                    reader.NextResult();
                    while (reader.Read())
                    {
                        var item = new Output.TransactionsLoanBookListData();

                        item.Title     = (reader.IsDBNull(0)) ? string.Empty : reader.GetString(0);
                        item.Price     = (reader.IsDBNull(1)) ? string.Empty : reader.GetString(1);
                        item.LoanDay   = (reader.IsDBNull(2)) ? DateTime.MinValue : reader.GetDateTime(2);
                        item.ReturnDay = (reader.IsDBNull(3)) ? DateTime.MinValue : reader.GetDateTime(3);
                        item.BookID    = (reader.IsDBNull(4)) ? 0 : reader.GetInt32(4);

                        obj.Content.Data.Add(item);
                    }
                }

                reader.Close();
            }

            retVal.Close();

            return(retVal);
        }