/// <code>
        /// reader會動態綁定資料庫hand在那
        /// var reader = cmd.ExecuteReader();
        /// while (reader.Read())
        /// { selectlist.Add(new SelectListItem { Text = reader.GetString(1), Value = reader.GetString(val) }); }
        /// reader.Close();
        /// </code>
        /// <param name="insertdata"></param>
        //新增借閱紀錄到資料庫
        public async Task InsertLendRecord(LendRecordInsert insertdata)
        {
            string sql = @"
						BEGIN TRY
							BEGIN TRANSACTION
								INSERT INTO BOOK_LEND_RECORD
								 (
									BOOK_ID,KEEPER_ID,LEND_DATE,CRE_DATE,CRE_USR,MOD_DATE,MOD_USR
								 )
								VALUES
								(
									 @BookId,@KeeperId, GETDATE(), 
									 GETDATE(), '123', GETDATE(), 
									'123'
								)
							COMMIT TRANSACTION
						End TRY
						BEGIN CATCH
							SELECT
								ERROR_NUMBER() AS ErrorNumber,
								ERROR_SEVERITY() AS ErrorSeverity,
								ERROR_STATE() as ErrorState,
								ERROR_PROCEDURE() as ErrorProcedure,
								ERROR_LINE() as ErrorLine,
								ERROR_MESSAGE() as ErrorMessage
							ROLLBACK TRANSACTION	
						END CATCH "                        ;

            using (SqlConnection conn = new SqlConnection(this.GetDBConnectionString()))
            {
                await conn.ExecuteAsync(sql, new
                {
                    BookId   = insertdata.BookID,
                    KeeperId = insertdata.BookKeeperId
                });
            }
        }
        public async Task <IActionResult> UpdateBook([FromBody] BookUpdate bookUpdate, [FromQuery] string IniBookStatus, [FromQuery] string LaterBookStatus)
        {
            //借閱人借閱狀態關係
            if ((bookUpdate.BookStatusId == "B" || bookUpdate.BookStatusId == "C") && (bookUpdate.BookKeeperId == "" || bookUpdate.BookKeeperId == null))
            {
                return(Ok("此借閱狀態,借閱人不能為空"));
            }
            else
            {
                //insert 借閱紀錄
                if ((IniBookStatus == "A" || IniBookStatus == "U") && (LaterBookStatus == "B" || LaterBookStatus == "C"))
                {
                    LendRecordInsert lendRecordInsert = new LendRecordInsert();
                    lendRecordInsert.BookKeeperId = bookUpdate.BookKeeperId;
                    lendRecordInsert.BookID       = Convert.ToInt32(bookUpdate.BookID);

                    await _bookservice.InsertLendRecord(lendRecordInsert);
                }
                //update 書本資料
                await _bookservice.UpdateBook(bookUpdate);

                return(Ok("編輯成功"));
            }
        }
 public void InsertLendRecord(LendRecordInsert insertdata)
 {
     throw new NotImplementedException();
 }