protected void bnt_Registro_Click(object sender, EventArgs e) { var idBilletera = Convert.ToInt32(txt_IdWallet.Text); var idTipoTransaccion = Convert.ToByte(txt_IdTransaction.Text); var monto = Convert.ToDecimal(txt_Amount.Text); var trans = new TransactionParam() { IdBilletera = idBilletera, IdTipoTransaccion = idTipoTransaccion, Monto = monto }; var transaction = AppServices.ConsultarApi( JsonConvert.SerializeObject(trans), recurso.RegistrarTransaccion ); var result = JsonConvert.DeserializeObject <TransactionDto>(transaction.Content); BindMyGrid(new RegistroBilletera() { IdWallet = trans.IdBilletera, IdTypeTransaction = trans.IdTipoTransaccion, Amount = result.Amount, Balance = result.Balance }); }
public IActionResult Search([FromBody] TransactionParam model) { //var user_session = HttpContext.Session.GetString("usersession"); var transaction_data = transactionRespository.GetTransaction(model); return(Json(transaction_data)); }
public string Transaction_Transfer(TransactionParam model) { using (var t = _context.Database.BeginTransaction()) { string check_status; try { if (Getbalance(model.TsAcId) >= model.TsMoney) { var account_payee = GetAccountId(model.TsAD); UpdateBalance(model.TsAcId, -model.TsMoney); var balance_transfer = Getbalance(model.TsAcId); addTransferor(model, account_payee, balance_transfer); UpdateBalance(account_payee, model.TsMoney); var balance_payee = Getbalance(account_payee); addPayee(model, account_payee, balance_transfer); check_status = Checkstatus.success; } else { check_status = Checkstatus.error_balance; } t.Commit(); } catch (Exception ex) { t.Rollback(); check_status = Checkstatus.error; } return(check_status); } }
public string Transaction_DepositWithdraw(TransactionParam model) { using (var t = _context.Database.BeginTransaction()) { string check_status; try { var check_balance = Getbalance(model.TsAcId); if (model.TsType == Checktype.withdraw && check_balance >= model.TsMoney) { UpdateBalance(model.TsAcId, -model.TsMoney); addDepositAndWithdraw(model); check_status = Checkstatus.successWithdraw; } else if (model.TsType == Checktype.depositor) { UpdateBalance(model.TsAcId, model.TsMoney); addDepositAndWithdraw(model); check_status = Checkstatus.successDeposit; } else { check_status = Checkstatus.error_balance; } t.Commit(); } catch (Exception ex) { t.Rollback(); check_status = Checkstatus.error; } return(check_status); } }
public JsonResult GetTransaction(TransactionParam prm) { string _status = "success"; string sSql = string.Empty; string errMsg = string.Empty; List <TransactionResult> list = new List <TransactionResult>(); DBManager objdbmgr = new DBManager(); sSql = ""; try { DataTable dt = objdbmgr.GetData(sSql, out errMsg); if (dt.Rows.Count > 0) { list = ObjectConverter.DataTableToList <TransactionResult>(dt); } } catch (Exception es) { _status = "Error"; errMsg = es.Message; } var JsonResult = Json(new { Data = list, Status = _status, ErrMsg = errMsg }, JsonRequestBehavior.AllowGet); JsonResult.MaxJsonLength = Int32.MaxValue; return(JsonResult); }
public List <TransactionViewModels> GetTransaction(TransactionParam model) { if (model.date_begin != "") { begin = DateTime.Parse(model.date_begin.ToString()); } if (model.date_end != "") { end = DateTime.Parse(model.date_end.ToString()); } IQueryable <TransactionViewModels> queryResult = from a in _context.Transaction join b in _context.Account on a.TsAcId equals b.AcId where b.UserId == model.UserId && (model.date_begin == "" || begin <= a.TsDate) && (model.date_end == "" || end >= a.TsDate) && (model.keyword == "" || (b.AcNumber.Contains(model.keyword) || a.TsDetail.Contains(model.keyword))) orderby a.TsId select new TransactionViewModels { TsId = a.TsId, name = b.AcNumber, TsAcId = a.TsAcId, Date1 = a.Date, TsAcDestinationId = a.TsAcDestinationId, TsBalance = a.TsBalance, TsMoney = a.TsMoney, TsDetail = a.TsDetail, TsType = a.TsType, }; return(queryResult.ToList()); }
public TransactionDto RegisterTransaction(TransactionParam param) { #region Proceso return(_model.RegisterTransaction(param)); #endregion }
public bool Insert(TransactionParam transactionParam) { var get = new Transaction(transactionParam); _Context.Transactions.Add(get); var result = _Context.SaveChanges(); if (result > 0) { status = true; } return(status); }
/// <summary> /// Updare LibraryBook /// </summary> /// <param name="LibraryBook"></param> /// <returns>The<see cref="int"/> </returns> public int UpdateLibraryBook(LibraryBookApiModel LibraryBook, TransactionParam transactionParam = null) { var parameters = new DynamicParameters(); parameters.Add(name: "LibraryBookCode", value: LibraryBook.LibraryBookCode); parameters.Add(name: "isbn", value: LibraryBook.ISBN); parameters.Add(name: "title", value: LibraryBook.Title); parameters.Add(name: "author", value: LibraryBook.Author); parameters.Add(name: "isStolen", value: LibraryBook.IsStolen); parameters.Add(name: "isLost", value: LibraryBook.IsLost); parameters.Add(name: "copyNumber", value: LibraryBook.CopyNumber); parameters.Add(name: "modifiedBy", value: LibraryBook.ModifiedBy); parameters.Add(name: "modifiedDate", value: DateTime.Now.ToString("yyyy-MM-dd H:mm:ss")); const string sql = @"UPDATE LibraryBook SET Title = @title ,ISBN = @isbn ,Title = @title ,Author = @author ,IsStolen = @isStolen ,IsLost = @isLost ,CopyNumber = @copyNumber ,ModifiedBy = @modifiedBy ,DateModified = @modifiedDate WHERE LibraryBookCode = @LibraryBookCode" ; LibraryBook.DateModified = DateTime.Now; int rowaffected = 0; if (transactionParam != null) { rowaffected = transactionParam.Connection.Execute( sql, param: parameters, commandType: CommandType.Text, transaction: transactionParam.Transaction); } else { using (var connection = this.OpenConnection()) { rowaffected = connection.Execute( sql, param: parameters, commandType: CommandType.Text); } } return(rowaffected); }
void addDepositAndWithdraw(TransactionParam model) { var transaction_deposit = new Transaction() { TsAcId = model.TsAcId, TsBalance = Getbalance(model.TsAcId), TsDate = DateTime.Now, TsMoney = model.TsMoney, TsDetail = model.TsDetail, TsType = model.TsType, }; _context.Transaction.Add(transaction_deposit); _context.SaveChanges(); }
void addPayee(TransactionParam model, int account_payee, decimal balance_payee) { var payee = new Transaction() { TsAcId = account_payee, TsBalance = balance_payee, TsDate = DateTime.Now, TsAcDestinationId = model.TsAcId, TsMoney = model.TsMoney, TsDetail = "เงินเข้าบัญชี", TsType = Checktype.payee, TsNote = model.TsNote, }; _context.Transaction.Add(payee); _context.SaveChanges(); }
void addTransferor(TransactionParam model, int account_payee, decimal balance_transfer) { var transfer = new Transaction() { TsAcId = model.TsAcId, TsBalance = balance_transfer, TsDate = DateTime.Now, TsAcDestinationId = account_payee, TsMoney = model.TsMoney, TsDetail = model.TsDetail, TsType = Checktype.transfer, TsNote = model.TsNote, }; _context.Transaction.Add(transfer); _context.SaveChanges(); }
public TransactionDto RegisterTransaction(TransactionParam param) { var result = new TransactionDto(); try { #region Proceso result = _transaction.RegisterTransaction(param); #endregion } catch (Exception Ex) { result.Messages.Add(new Error() { Message = Ex.Message }); } return(result); }
/// <summary> /// Updare LibraryUser /// </summary> /// <param name="libraryUser"></param> /// <returns>The<see cref="int"/> </returns> public int UpdateLibraryUser(LibraryUserApiModel libraryUser, TransactionParam transactionParam = null) { return(this._libraryUserRepository.UpdateLibraryUser(libraryUser, transactionParam)); }
/// <summary> /// Insert LibraryBookStatus /// </summary> /// <param name="libraryBookStatus"></param> /// <param name="libraryBookStatusCode"></param> /// <returns>The<see cref="int"/> </returns> public virtual int InsertLibraryBookStatus(LibraryBookStatusApiModel libraryBookStatus, out string libraryBookStatusCode, TransactionParam transactionParam = null) { libraryBookStatusCode = _randomKeyGenerator.GetUniqueKey(9); libraryBookStatus.LibraryBookStatusCode = libraryBookStatusCode; var parameters = new DynamicParameters(); parameters.Add(name: "libraryBookStatusCode", value: libraryBookStatusCode); parameters.Add(name: "dateCheckedOut", value: libraryBookStatus.DateCheckedOut); parameters.Add(name: "dateReturned", value: libraryBookStatus.DateReturned); parameters.Add(name: "libraryUserCode", value: libraryBookStatus.LibraryUser.LibraryUserCode); parameters.Add(name: "createdBy", value: libraryBookStatus.CreatedBy); //parameters.Add(name: "dateCreated", value: libraryBookStatus.DateCreated); parameters.Add(name: "modifiedBy", value: libraryBookStatus.ModifiedBy); //parameters.Add(name: "dateModified", value: libraryBookStatus.DateModified); int rowaffected = 0; string sql = @"INSERT INTO LibraryBookStatus ( LibraryBookStatusCode, DateCheckedOut, DateReturned, DateCreated, CreatedBy, DateModified, ModifiedBy, LibraryBookId, LibraryBookUserId ) SELECT @libraryBookStatusCode, @dateCheckedOut, @dateReturned, NOW(), @createdBy, NOW(), @modifiedBy, @libraryBookId, LU.LibraryUserId FROM LibraryUser LU WHERE LU.LibraryUserCode = @libraryUserCode"; if (transactionParam != null) { int bookId = transactionParam.Connection.Query <int>(@"SELECT LibraryBookId FROM LibraryBook WHERE LibraryBookCode = @libraryBookCode", new { libraryBookStatus.LibraryBook.LibraryBookCode } ).SingleOrDefault(); parameters.Add(name: "@libraryBookId", value: bookId); rowaffected = transactionParam.Connection.Execute( sql, param: parameters, commandType: CommandType.Text, transaction: transactionParam.Transaction); } else { using (var connection = this.OpenConnection()) { int bookId = connection.Query <int>(@"SELECT LibraryBookId FROM LibraryBook WHERE LibraryBookCode = @libraryBookCode", new { libraryBookStatus.LibraryBook.LibraryBookCode } ).SingleOrDefault(); parameters.Add(name: "@libraryBookId", value: bookId); rowaffected = connection.Execute( sql, param: parameters, commandType: CommandType.Text); } } return(rowaffected); }
public Transaction(TransactionParam transactionParam) { this.Id = transactionParam.Transactions_Id; this.TransactionCode = transactionParam.TransactionCode; this.TransactionDate = DateTimeOffset.Now.LocalDateTime; }
public void Insert(TransactionParam transactionParam) { _detailTransactionRepository.Insert(transactionParam); }
/// <summary> /// Insert LibraryBookStatus /// </summary> /// <param name="libraryBookStatus"></param> /// <param name="libraryBookStatusCode"></param> /// <returns>The<see cref="int"/> </returns> public int InsertLibraryBookStatus(LibraryBookStatusApiModel libraryBookStatus, out string libraryBookStatusCode, TransactionParam transactionParam = null) { return(_libraryBookStatusRepository.InsertLibraryBookStatus(libraryBookStatus, out libraryBookStatusCode, transactionParam)); }
/// <summary> /// Updare LibraryBookStatus /// </summary> /// <param name="libraryBookStatus"></param> /// <returns>The<see cref="int"/> </returns> public int UpdateLibraryBookStatus(LibraryBookStatusApiModel libraryBookStatus, TransactionParam transactionParam = null) { return(_libraryBookStatusRepository.UpdateLibraryBookStatus(libraryBookStatus, transactionParam)); }
public ActionResult Create(TransactionParam transactionParam) { return(Json(JsonRequestBehavior.AllowGet)); }
public TransactionDto RegisterTransaction(TransactionParam param) { var result = new TransactionDto(); result.Response = false; try { #region Validaciones if (param.IdBilletera < 0) { result.Messages.Add(new Error() { Message = recurso.IdBilletera }); } if (param.IdTipoTransaccion < 0) { result.Messages.Add(new Error() { Message = recurso.IdTransaccion }); } if (param.Monto == 0) { result.Messages.Add(new Error() { Message = recurso.Monto }); } if (result.Messages.Count == 0) { result.Response = true; var register = BDFile.LeeArchivo(recursoBD.UrlFile); decimal balance = 0; if (!String.IsNullOrWhiteSpace(register)) { balance = Convert.ToDecimal(register); } result.Amount = param.Monto; _balance = balance + param.Monto; BDFile.EscribeEnArchivo(_balance.ToString(), recursoBD.UrlFile); result.Balance = _balance; } #endregion } catch (Exception ex) { result.Messages.Add(new Error() { Message = ex.Message }); } return(result); }
public void Post(TransactionParam transactionParam) { _transactionService.Insert(transactionParam); }
public DetailTransaction(TransactionParam transactionParam) { this.Id = transactionParam.DetailTransactions_Id; this.Quantity = transactionParam.DetailTransactions_Quantity; this.Price = transactionParam.DetailTransactions_Price; }
public IActionResult Transfer([FromBody] TransactionParam model) { check_status = transactionRespository.Transaction_Transfer(model); return(Json(check_status)); }
/// <summary> /// Insert LibraryUser /// </summary> /// <param name="LibraryUser"></param> /// <param name="LibraryUserCode"></param> /// <returns>The<see cref="int"/> </returns> public virtual int InsertLibraryUser(LibraryUserApiModel LibraryUser, out string LibraryUserCode, TransactionParam transactionParam = null) { LibraryUserCode = _randomKeyGenerator.GetUniqueKey(9); LibraryUser.LibraryUserCode = LibraryUserCode; var parameters = new DynamicParameters(); parameters.Add(name: "LibraryUserCode", value: LibraryUserCode); parameters.Add(name: "title", value: LibraryUser.Title); parameters.Add(name: "name", value: LibraryUser.Name); parameters.Add(name: "phoneNumber", value: LibraryUser.PhoneNumber); parameters.Add(name: "mobilePhoneNumber", value: LibraryUser.MobilePhoneNumber); parameters.Add(name: "email", value: LibraryUser.Email); parameters.Add(name: "alternativePhoneNumber", value: LibraryUser.AlternativePhoneNumber); parameters.Add(name: "alternativeEmail", value: LibraryUser.AlternativeEmail); parameters.Add(name: "addressLine1", value: LibraryUser.AddressLine1); parameters.Add(name: "addressLine2", value: LibraryUser.AddressLine2); parameters.Add(name: "addressLine3", value: LibraryUser.AddressLine3); parameters.Add(name: "city", value: LibraryUser.City); parameters.Add(name: "county", value: LibraryUser.County); parameters.Add(name: "country", value: LibraryUser.Country); parameters.Add(name: "postcode", value: LibraryUser.Postcode); parameters.Add(name: "GDPRInformedDate", value: LibraryUser.GDPRInformedDate); parameters.Add(name: "GDPRInformedBy", value: LibraryUser.GDPRInformedBy); parameters.Add(name: "GDPRHowInformed", value: LibraryUser.GDPRHowInformed); parameters.Add(name: "GDPRNotes", value: LibraryUser.GDPRNotes); parameters.Add(name: "LibraryUserByPost", value: LibraryUser.LibraryUserByPost); parameters.Add(name: "LibraryUserByPostConsentDate", value: LibraryUser.LibraryUserByPostConsentDate); parameters.Add(name: "LibraryUserByEmail", value: LibraryUser.LibraryUserByEmail); parameters.Add(name: "LibraryUserByEmailConsentDate", value: LibraryUser.LibraryUserByEmailConsentDate); parameters.Add(name: "LibraryUserByPhone", value: LibraryUser.LibraryUserByPhone); parameters.Add(name: "LibraryUserByPhoneConsentDate", value: LibraryUser.LibraryUserByPhoneConsentDate); parameters.Add(name: "LibraryUserBySMS", value: LibraryUser.LibraryUserBySMS); parameters.Add(name: "LibraryUserBySMSConsentDate", value: LibraryUser.LibraryUserBySMSConsentDate); parameters.Add(name: "createdBy", value: LibraryUser.CreatedBy); parameters.Add(name: "dateCreated", value: LibraryUser.DateCreated); parameters.Add(name: "modifiedBy", value: LibraryUser.ModifiedBy); parameters.Add(name: "dateModified", value: LibraryUser.DateModified); int rowaffected = 0; string sql = @"INSERT INTO LibraryUser ( LibraryUserCode,Title,Name,PhoneNumber,MobilePhoneNumber,Email, AlternativePhoneNumber, AlternativeEmail, AddressLine1, AddressLine2, AddressLine3, City, County, Country, Postcode, GDPRInformedDate,GDPRInformedBy,GDPRHowInformed,GDPRNotes,LibraryUserByPost,LibraryUserByPostConsentDate,LibraryUserByEmail, LibraryUserByEmailConsentDate,LibraryUserByPhone,LibraryUserByPhoneConsentDate,LibraryUserBySMS,LibraryUserBySMSConsentDate, CreatedBy, DateCreated, ModifiedBy, DateModified ) VALUES( @LibraryUserCode, @title, @name, @phoneNumber, @mobilePhoneNumber, @email, @alternativePhoneNumber, @alternativeEmail, @addressLine1, @addressLine2, @addressLine3, @city, @county, @country, @postcode, @GDPRInformedDate,@GDPRInformedBy,@GDPRHowInformed,@GDPRNotes,@LibraryUserByPost,@LibraryUserByPostConsentDate,@LibraryUserByEmail, @LibraryUserByEmailConsentDate,@LibraryUserByPhone,@LibraryUserByPhoneConsentDate,@LibraryUserBySMS,@LibraryUserBySMSConsentDate, @createdBy, NOW(), @modifiedBy, NOW())" ; if (transactionParam != null) { rowaffected = transactionParam.Connection.Execute( sql, param: parameters, commandType: CommandType.Text, transaction: transactionParam.Transaction); } else { using (var connection = this.OpenConnection()) { rowaffected = connection.Execute( sql, param: parameters, commandType: CommandType.Text); } } return(rowaffected); }
/// <summary> /// Updare LibraryUser /// </summary> /// <param name="LibraryUser"></param> /// <returns>The<see cref="int"/> </returns> public int UpdateLibraryUser(LibraryUserApiModel LibraryUser, TransactionParam transactionParam = null) { var parameters = new DynamicParameters(); parameters.Add(name: "LibraryUserCode", value: LibraryUser.LibraryUserCode); parameters.Add(name: "title", value: LibraryUser.Title); parameters.Add(name: "name", value: LibraryUser.Name); parameters.Add(name: "phoneNumber", value: LibraryUser.PhoneNumber); parameters.Add(name: "mobilePhoneNumber", value: LibraryUser.MobilePhoneNumber); parameters.Add(name: "email", value: LibraryUser.Email); parameters.Add(name: "alternativePhoneNumber", value: LibraryUser.AlternativePhoneNumber); parameters.Add(name: "alternativeEmail", value: LibraryUser.AlternativeEmail); parameters.Add(name: "addressLine1", value: LibraryUser.AddressLine1); parameters.Add(name: "addressLine2", value: LibraryUser.AddressLine2); parameters.Add(name: "addressLine3", value: LibraryUser.AddressLine3); parameters.Add(name: "city", value: LibraryUser.City); parameters.Add(name: "county", value: LibraryUser.County); parameters.Add(name: "country", value: LibraryUser.Country); parameters.Add(name: "postcode", value: LibraryUser.Postcode); parameters.Add(name: "GDPRInformedDate", value: LibraryUser.GDPRInformedDate); parameters.Add(name: "GDPRInformedBy", value: LibraryUser.GDPRInformedBy); parameters.Add(name: "GDPRHowInformed", value: LibraryUser.GDPRHowInformed); parameters.Add(name: "GDPRNotes", value: LibraryUser.GDPRNotes); parameters.Add(name: "LibraryUserByPost", value: LibraryUser.LibraryUserByPost); parameters.Add(name: "LibraryUserByPostConsentDate", value: LibraryUser.LibraryUserByPostConsentDate); parameters.Add(name: "LibraryUserByEmail", value: LibraryUser.LibraryUserByEmail); parameters.Add(name: "LibraryUserByEmailConsentDate", value: LibraryUser.LibraryUserByEmailConsentDate); parameters.Add(name: "LibraryUserByPhone", value: LibraryUser.LibraryUserByPhone); parameters.Add(name: "LibraryUserByPhoneConsentDate", value: LibraryUser.LibraryUserByPhoneConsentDate); parameters.Add(name: "LibraryUserBySMS", value: LibraryUser.LibraryUserBySMS); parameters.Add(name: "LibraryUserBySMSConsentDate", value: LibraryUser.LibraryUserBySMSConsentDate); parameters.Add(name: "modifiedBy", value: LibraryUser.ModifiedBy); parameters.Add(name: "modifiedDate", value: DateTime.Now); const string sql = @"UPDATE LibraryUser SET Title = @title ,Name = @name ,PhoneNumber = @phoneNumber ,MobilePhoneNumber = @mobilePhoneNumber ,Email = @email ,AlternativePhoneNumber = @alternativePhoneNumber ,AlternativeEmail = @alternativeEmail ,AddressLine1 = @addressLine1 ,AddressLine2 = @addressLine2 ,AddressLine3 = @addressLine3 ,City = @city ,County = @county ,Country = @country ,Postcode = @postcode ,GDPRInformedDate = @GDPRInformedDate ,GDPRInformedBy = @GDPRInformedBy ,GDPRHowInformed = @GDPRHowInformed ,GDPRNotes = @GDPRNotes ,LibraryUserByPost = @LibraryUserByPost ,LibraryUserByPostConsentDate = @LibraryUserByPostConsentDate ,LibraryUserByEmail = @LibraryUserByEmail ,LibraryUserByEmailConsentDate = @LibraryUserByEmailConsentDate ,LibraryUserByPhone = @LibraryUserByPhone ,LibraryUserByPhoneConsentDate = @LibraryUserByPhoneConsentDate ,LibraryUserBySMS = @LibraryUserBySMS ,LibraryUserBySMSConsentDate = @LibraryUserBySMSConsentDate ,ModifiedBy = @modifiedBy ,DateModified = @modifiedDate WHERE LibraryUserCode = @LibraryUserCode" ; LibraryUser.DateModified = DateTime.Now; int rowaffected = 0; if (transactionParam != null) { rowaffected = transactionParam.Connection.Execute( sql, param: parameters, commandType: CommandType.Text, transaction: transactionParam.Transaction); } else { using (var connection = this.OpenConnection()) { rowaffected = connection.Execute( sql, param: parameters, commandType: CommandType.Text); } } return(rowaffected); }
public IActionResult Deposit_Withdraw([FromBody] TransactionParam model) { check_status = transactionRespository.Transaction_DepositWithdraw(model); return(Json(check_status)); }
/// <summary> /// Insert LibraryUser /// </summary> /// <param name="libraryUser"></param> /// <param name="libraryUserCode"></param> /// <returns>The<see cref="int"/> </returns> public int InsertLibraryUser(LibraryUserApiModel libraryUser, out string libraryUserCode, TransactionParam transactionParam = null) { return(this._libraryUserRepository.InsertLibraryUser(libraryUser, out libraryUserCode, transactionParam)); }
/// <summary> /// Updare LibraryBookStatus /// </summary> /// <param name="libraryBookStatus"></param> /// <returns>The<see cref="int"/> </returns> public int UpdateLibraryBookStatus(LibraryBookStatusApiModel libraryBookStatus, TransactionParam transactionParam = null) { var parameters = new DynamicParameters(); parameters.Add(name: "LibraryBookStatusCode", value: libraryBookStatus.LibraryBookStatusCode); parameters.Add(name: "dateCheckedOut", value: libraryBookStatus.DateCheckedOut); parameters.Add(name: "dateReturned", value: libraryBookStatus.DateReturned); parameters.Add(name: "modifiedBy", value: libraryBookStatus.ModifiedBy); parameters.Add(name: "modifiedDate", value: DateTime.Now); const string sql = @"UPDATE LibraryBookStatus SET DateCheckedOut = @dateCheckedOut ,DateReturned = @dateReturned ,ModifiedBy = @modifiedBy ,DateModified = @modifiedDate WHERE LibraryBookStatusCode = @LibraryBookStatusCode" ; libraryBookStatus.DateModified = DateTime.Now; int rowaffected = 0; if (transactionParam != null) { rowaffected = transactionParam.Connection.Execute( sql, param: parameters, commandType: CommandType.Text, transaction: transactionParam.Transaction); } else { using (var connection = this.OpenConnection()) { rowaffected = connection.Execute( sql, param: parameters, commandType: CommandType.Text); } } return(rowaffected); }
/// <summary> /// Insert LibraryBook /// </summary> /// <param name="LibraryBook"></param> /// <param name="LibraryBookCode"></param> /// <returns>The<see cref="int"/> </returns> public virtual int InsertLibraryBook(LibraryBookApiModel LibraryBook, out string LibraryBookCode, TransactionParam transactionParam = null) { LibraryBookCode = _randomKeyGenerator.GetUniqueKey(9); LibraryBook.LibraryBookCode = LibraryBookCode; var parameters = new DynamicParameters(); parameters.Add(name: "LibraryBookCode", value: LibraryBookCode); parameters.Add(name: "isbn", value: LibraryBook.ISBN); parameters.Add(name: "title", value: LibraryBook.Title); parameters.Add(name: "author", value: LibraryBook.Author); parameters.Add(name: "isStolen", value: LibraryBook.IsStolen); parameters.Add(name: "isLost", value: LibraryBook.IsLost); parameters.Add(name: "copyNumber", value: LibraryBook.CopyNumber); parameters.Add(name: "createdBy", value: LibraryBook.CreatedBy); //parameters.Add(name: "dateCreated", value: LibraryBook.DateCreated.ToString("yyyy-MM-dd H:mm:ss")); parameters.Add(name: "modifiedBy", value: LibraryBook.ModifiedBy); //parameters.Add(name: "dateModified", value: LibraryBook.DateModified.ToString("yyyy-MM-dd H:mm:ss")); int rowaffected = 0; string sql = @"INSERT INTO LibraryBook ( LibraryBookCode, ISBN, Title, Author, IsStolen, IsLost, CopyNumber, CreatedBy, ModifiedBy) VALUES (@libraryBookCode, @isbn, @title, @author, @isStolen, @isLost, @copyNumber, @createdBy, @modifiedBy)" ; if (transactionParam != null) { rowaffected = transactionParam.Connection.Execute( sql, param: parameters, commandType: CommandType.Text, transaction: transactionParam.Transaction); } else { using (var connection = this.OpenConnection()) { rowaffected = connection.Execute( sql, param: parameters, commandType: CommandType.Text); } } return(rowaffected); }