public ActionResult Create(int fundId, Transaction.TransactionType type) { ViewBag.Fund = db.SavingsFunds.Find(fundId); ViewBag.TransactionType = type.ToString(); return(View()); }
public TransactionRecorded(string txId, Quantity quantity, Transaction.TransactionType transactionType, string comment) { TxId = txId; Quantity = quantity; TransactionType = transactionType; Comment = comment; }
public RecordTransaction(string txId, Quantity amount, Transaction.TransactionType transactionType, string comment) { TxId = txId; Amount = amount; TransactionType = transactionType; Comment = comment; }
public void TransactionsOfEachType(Transaction.TransactionType type) { var transactionsFactory = new TransactionsFactory(); var transactions = transactionsFactory.GetTransactions().Take(50).ToList(); Assert.Contains(transactions, t => t.Type.Equals(type)); }
public Transaction AddTransaction(Transaction.TransactionType transactionType, double amount) { var balance = GetWalletBalance(); if (transactionType == Transaction.TransactionType.Payment) { balance += amount; } else { balance -= amount; } if (balance < 0) { return(null); } var transaction = new Transaction { Type = transactionType, Amount = Math.Round(amount, 2), Time = DateTime.Now, Balance = Math.Round(balance, 2) }; Create(transaction); Save(); return(transaction); }
public TransactionInfo(string txId, NodaTime.Instant date, Quantity quantity, Transaction.TransactionType transactionType, string comment) { TxId = txId; Date = date; Quantity = quantity; TransactionType = transactionType; Comment = comment; }
public Transaction AddTransaction(Transaction.TransactionType transactionType, double amount) { var balance = GetWalletBalance(); var transaction = new Transaction { Id = _transactions.Last().Id++, Type = transactionType, Amount = amount, Time = DateTime.Today, Balance = balance + amount }; _transactions.Add(transaction); return(_transactions.Last()); }
// funciton that creates a transaction for user public TransactionModels.TransactionFeedback AddTransaction(long userId, decimal amount, Transaction.TransactionType transactionType) { // amount should be positive if (amount < 0) { // return error return(new TransactionModels.TransactionFeedback { Success = false, Errors = "Amount should be more than 0", TransactionType = transactionType }); } // check if user valid var user = GetUser(userId); if (user == null) { // return error return(new TransactionModels.TransactionFeedback { Success = false, Errors = "Cannot validate user.", TransactionType = transactionType }); } // create withdraw transaction for user var prevTrans = GetLastTransactionForUser(userId); var prevBalance = prevTrans?.CurrentBalance ?? 0; // check if new balance is below limit var currBal = prevBalance + (transactionType == Transaction.TransactionType.Deposit ? amount : -amount); if (currBal < 0) { // return error return(new TransactionModels.TransactionFeedback { Success = false, Errors = "Cannot withdraw more than available balance.", TransactionType = transactionType }); } var transaction = new Transaction { UserId = userId, Date = DateTime.Now, Type = (int)transactionType, Amount = amount, PrevBalance = prevBalance, CurrentBalance = currBal }; //add using (var db = new AppDbContext()) { db.Transactions.Add(transaction); db.SaveChanges(); } // return return(new TransactionModels.TransactionFeedback { Success = true, TransactionType = transactionType }); }
public UpdateTransactionDetails(string txId, Transaction.TransactionType transactionType, string comment) { TxId = txId; TransactionType = transactionType; Comment = comment; }
public TransactionDetailsUpdated(Transaction.TransactionType transactionType, string comment) { TransactionType = transactionType; Comment = comment; }
public void UpdateDetails(Transaction.TransactionType transactionType, string comment) { When(new Chronos.Core.Events.TransactionDetailsUpdated(transactionType, comment)); }
public Transaction(string txId, Quantity quantity, Transaction.TransactionType transactionType, string comment) : this() { When(new Chronos.Core.Events.TransactionRecorded(txId, quantity, transactionType, comment)); }
public List <Transaction> TransactionHistory() { List <Transaction> listTransaction = new List <Transaction>(); DbConnection.Instance().OpenConnection(); //Đảm bảo đã kết nối đến database thành công var transaction = DbConnection.Instance().Connection.BeginTransaction(); var listTransactionHistory = 0; var queryTransactionHistory = "select * from transaction where accountNumber = @accountNumber and status = 1"; MySqlCommand queryReceiBalanceCommand = new MySqlCommand(queryTransactionHistory, DbConnection.Instance().Connection); var reader = queryReceiBalanceCommand.ExecuteReader(); while (reader.Read()) { var id = reader.GetString("id"); var amount = reader.GetDecimal("amount"); var content = reader.GetString("content"); var senderAccountNumber = reader.GetString("senderAccountNumber"); var receiAccountNumber = reader.GetString("receiAccountNumber"); var type = reader.GetInt32("type"); Transaction.TransactionType typeTransaction = Transaction.TransactionType.DEPOSIT; if (type == 1) { typeTransaction = Transaction.TransactionType.DEPOSIT; } else if (type == 2) { typeTransaction = Transaction.TransactionType.WITHDRAW; } else if (type == 3) { typeTransaction = Transaction.TransactionType.TRANSFER; } var createdAt = reader.GetString("createdAt"); var status = reader.GetInt32("status"); Transaction.ActiveStatus statusTransaction = Transaction.ActiveStatus.REJECT; if (status == 0) { statusTransaction = Transaction.ActiveStatus.REJECT; } else if (status == 1) { statusTransaction = Transaction.ActiveStatus.PROCESSING; } else if (status == 2) { statusTransaction = Transaction.ActiveStatus.DONE; } else if (status == -1) { statusTransaction = Transaction.ActiveStatus.DELETED; } Transaction tran = new Transaction(id, amount, content, senderAccountNumber, receiAccountNumber, typeTransaction, createdAt, statusTransaction); listTransaction.Add(tran); } return(listTransaction); }