public ActionResult DeleteConfirmed(int id) { BankAcct bankAcct = db.BankAccts.Find(id); db.BankAccts.Remove(bankAcct); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "id,title,added,updated,householdId")] BankAcct updatedBankAcct) { if (ModelState.IsValid) { updatedBankAcct.updated = DateTimeOffset.UtcNow; db.Entry(updatedBankAcct).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(updatedBankAcct)); }
static void Main(string[] args) { BankAcct acct = new BankAcct(10); Thread[] threads = new Thread[15]; // CurrentThread gets you the current // executing thread Thread.CurrentThread.Name = "main"; // Create 15 threads that will call for // IssueWithdraw to execute for (int i = 0; i < 15; i++) { // You can only point at methods // without arguments and that return // nothing Thread t = new Thread(new ThreadStart(acct.IssueWithdraw)); t.Name = i.ToString(); threads[i] = t; } // Have threads try to execute for (int i = 0; i < 15; i++) { // Check if thread has started Console.WriteLine("Thread {0} Alive : {1}", threads[i].Name, threads[i].IsAlive); Thread.Sleep(500); // Start thread threads[i].Start(); // Check if thread has started Console.WriteLine("Thread {0} Alive : {1}", threads[i].Name, threads[i].IsAlive); } // Get thread priority (Normal Default) // Also Lowest, BelowNormal, AboveNormal // and Highest // changing priority doesn't guarantee // the highest precedence though // It is best to not mess with this Console.WriteLine("Current Priority : {0}", Thread.CurrentThread.Priority); Console.WriteLine("Thread {0} Ending", Thread.CurrentThread.Name); Console.ReadLine(); }
// GET: BankAccts/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } BankAcct bankAcct = db.BankAccts.Find(id); if (bankAcct == null) { return(HttpNotFound()); } return(View(bankAcct)); }
public ActionResult OverDraftCheck() { decimal numIn = decimal.Parse(Request.Form[0]); int bankAcctId = int.Parse(Request.Form[1]); BankAcct acct = db.BankAccts.Find(bankAcctId); decimal newBal = acct.balance - numIn; if (newBal > 0) { return(Json(new { overdraft = false }, JsonRequestBehavior.AllowGet)); } else { return(Json(new { overdraft = true }, JsonRequestBehavior.AllowGet)); } }
private BaseTender GetTender(PaymentInfo paymentInfo) { if (paymentInfo is CreditCardPaymentInfo) { var cc = paymentInfo as CreditCardPaymentInfo; var ppCreditCard = new CreditCard(cc.Number, cc.ExpirationDate.ToString("MMyy")); ppCreditCard.Cvv2 = cc.Code; return(new CardTender(ppCreditCard)); } if (paymentInfo is ACHPaymentInfo) { var ach = paymentInfo as ACHPaymentInfo; var ppBankAccount = new BankAcct(ach.BankAccountNumber, ach.BankRoutingNumber); ppBankAccount.AcctType = ach.AccountType == BankAccountType.Checking ? "C" : "S"; return(new ACHTender(ppBankAccount)); } if (paymentInfo is SwipePaymentInfo) { var swipe = paymentInfo as SwipePaymentInfo; var ppSwipeCard = new SwipeCard(swipe.SwipeInfo); return(new CardTender(ppSwipeCard)); } if (paymentInfo is ReferencePaymentInfo) { var reference = paymentInfo as ReferencePaymentInfo; if (reference.CurrencyTypeValue != null && reference.CurrencyTypeValue.Guid.Equals(new Guid(Rock.SystemGuid.DefinedValue.CURRENCY_TYPE_ACH))) { return(new ACHTender(( BankAcct )null)); } else { return(new CardTender(( CreditCard )null)); } } return(null); }
public ActionResult Create(string title, decimal balance) { //[Bind(Include = "title,balance")] BankAcct bankAcct){ if (title != "" || title != null) { BankAcct bankAcct = new BankAcct() { title = title, householdId = User.Identity.GetHouseId(), added = DateTimeOffset.UtcNow }; db.BankAccts.Add(bankAcct); db.SaveChanges(); Transaction transaction = new Transaction() { description = "Account Seed", amount = balance, bankAcctId = bankAcct.id, creatorId = User.Identity.GetUserId(), date = DateTimeOffset.UtcNow, transactionTypeId = 2 }; db.Transactions.Add(transaction); db.SaveChanges(); return(RedirectToAction("Details", new { id = bankAcct.id })); } return(View()); //if (ModelState.IsValid){ //bankAcct.added = DateTimeOffset.UtcNow; //bankAcct.householdId = (int)User.Identity.GetHouseholdId(); //db.BankAccts.Add(bankAcct); //db.SaveChanges(); //return RedirectToAction("Index"); //} //return View(bankAcct); }
static void Main(string[] args) { // Example of threads running /* * Thread t = new Thread(Print1); * * t.Start(); * * for (int i = 0; i < 1000; i++) * { * Console.Write(0); * } */ // int num = 1; // Sleep allows us to slow down a thread /* * for(int i = 0; i < 10; i++) * { * Console.WriteLine(num); * Thread.Sleep(1000); * num++; * } * Console.WriteLine("Thread Ends"); */ BankAcct acct = new BankAcct(10); Thread[] threads = new Thread[15]; Thread.CurrentThread.Name = "main"; for (int i = 0; i < 15; i++) { Thread t = new Thread(new ThreadStart(acct.IssueWithdraw)); t.Name = i.ToString(); threads[i] = t; } for (int i = 0; i < 15; i++) { Console.WriteLine("Thread {0} Alive: {1}", threads[i].Name, threads[i].IsAlive); threads[i].Start(); } Console.WriteLine("Current Priority : {0}", Thread.CurrentThread.Priority); Console.WriteLine("Thread {0} Ending", Thread.CurrentThread.Name); // Example of passing parameters to a thread Thread t2 = new Thread(() => CountTo(10)); t2.Start(); // Example of creating multiple threads simultaneously new Thread(() => { CountTo(5); CountTo(6); }).Start(); Console.ReadLine(); }
public ActionResult Open([Bind(Include = "HouseholdId,AccountName,HeldAt,AccountNumber,OpeningBalance,OpeningDate,BalanceCurrent")] BankAcctViewModel bankAcct) { if (ModelState.IsValid) { bankAcct.AccountName = bankAcct.HeldAt + "::" + bankAcct.AccountNumber; if (db.BankAccts.Any(a => a.AccountName == bankAcct.AccountName)) { ModelState.AddModelError("AccountName", "Please enter a unique Account number for this Institution."); return View(bankAcct); } if (bankAcct.OpeningDate == null) bankAcct.OpeningDate = System.DateTimeOffset.Now; var newBankAcct = new BankAcct(); newBankAcct.AccountNumber = bankAcct.AccountNumber; newBankAcct.HeldAt = bankAcct.HeldAt; newBankAcct.AccountName = bankAcct.AccountName; newBankAcct.HouseholdId = bankAcct.HouseholdId; newBankAcct.Opened = bankAcct.OpeningDate; newBankAcct.BalanceCurrent = bankAcct.OpeningBalance; db.BankAccts.Add(newBankAcct); if (bankAcct.OpeningBalance != 0) { var openDeal = new Deal(); openDeal.BankAcctId = newBankAcct.Id; var cat = db.Categories.FirstOrDefault(c => c.HouseholdId == newBankAcct.HouseholdId && c.Name == "Other Income"); openDeal.CategoryId = cat.Id; openDeal.Amount = bankAcct.OpeningBalance; openDeal.DealDate = (DateTimeOffset)bankAcct.OpeningDate; openDeal.Description = "Opening Transaction"; openDeal.Payee = "Deposit"; openDeal.Reconciled = false; db.Deals.Add(openDeal); } db.SaveChanges(); return RedirectToAction("Index", "BankAccts"); } return RedirectToAction("Index", "BankAccts"); }
private BaseTender GetTender( PaymentInfo paymentInfo ) { if ( paymentInfo is CreditCardPaymentInfo ) { var cc = paymentInfo as CreditCardPaymentInfo; var ppCreditCard = new CreditCard( cc.Number, cc.ExpirationDate.ToString( "MMyy" ) ); ppCreditCard.Cvv2 = cc.Code; return new CardTender( ppCreditCard ); } if ( paymentInfo is ACHPaymentInfo ) { var ach = paymentInfo as ACHPaymentInfo; var ppBankAccount = new BankAcct( ach.BankAccountNumber, ach.BankRoutingNumber ); ppBankAccount.AcctType = ach.AccountType == BankAccountType.Checking ? "C" : "S"; ppBankAccount.Name = ach.BankName; return new ACHTender( ppBankAccount ); } if ( paymentInfo is SwipePaymentInfo ) { var swipe = paymentInfo as SwipePaymentInfo; var ppSwipeCard = new SwipeCard( swipe.SwipeInfo ); return new CardTender( ppSwipeCard ); } if ( paymentInfo is ReferencePaymentInfo ) { var reference = paymentInfo as ReferencePaymentInfo; if ( reference.CurrencyTypeValue.Guid.Equals( new Guid( Rock.SystemGuid.DefinedValue.CURRENCY_TYPE_ACH ) ) ) { return new ACHTender( (BankAcct)null ); } else { return new CardTender( (CreditCard)null ); } } return null; }
static void Main(string[] args) { BankAcct acct = new BankAcct(10); Thread[] threads = new Thread[15]; Thread.CurrentThread.Name = "main"; for (int i = 0; i < 15; i++) { Thread t = new Thread(new ThreadStart (acct.IssueWithdraw)); t.Name = i.ToString(); threads[i] = t; } for (int i = 0; i < 15; i++) { Console.WriteLine("Thread {0} Alive :" + "{1}", threads[i].Name, threads[i].IsAlive); threads[i].Start(); Console.WriteLine("Thread {0} Alive :" + "{1}", threads[i].Name, threads[i].IsAlive); } Console.WriteLine("Current Priority :{0}", Thread.CurrentThread.Priority); Console.WriteLine("Thread {0} Ending", Thread.CurrentThread.Name); Console.ReadLine(); /*int num = 1; * * for (int i = 0; i < 10; i++) * { * Console.WriteLine(num); * Thread.Sleep(1000); //1000 here stands for 1000ms, so basically 1 second * num++; * } * Console.Write("Thread ends here"); * * * Console.ReadLine();*/ /*Thread t = new Thread(Print1); * * t.Start(); * * for (int i = 0; i < 1000; i++) // this is one thread * { * Console.Write(0); * } * * Console.ReadLine(); ;*/ }
public ActionResult Create([Bind(Include = "id,description,amount,reconciledAmount,date,reconciledDate," + "recurring,creatorId,updaterId,bankAcctId," + "transactionTypeId,voided")] Transaction transaction, HttpPostedFileBase fileInput2) { if (Request.Form.Count >= 8) { ApplicationUser user = db.Users.Find(User.Identity.GetUserId()); Household house = db.Households.Find(user.householdId); Transaction newTransaction = new Transaction() { description = Request.Form[0], amount = decimal.Parse(Request.Form[1]), date = DateTimeOffset.Parse(Request.Form[2]), frequency = int.Parse(Request.Form[4]), bankAcctId = int.Parse(Request.Form[5]), budgetId = int.Parse(Request.Form[6]), //transactionCatagoryId = int.Parse(Request.Form[7]), transactionTypeId = int.Parse(Request.Form[7]), creatorId = user.Id }; if (Request.Form[3] == "on") { newTransaction.recurring = true; } else if (Request.Form[3] == "off") { newTransaction.recurring = false; } BankAcct acct = db.BankAccts.Find(newTransaction.bankAcctId); if (newTransaction.transactionTypeId == 1) { //acct.balance -= newTransaction.amount; } else if (newTransaction.transactionTypeId == 2) { //acct.balance += newTransaction.amount; } if (Request.Files.Count > 0) { HttpPostedFileBase file = Request.Files[0]; var ext = Path.GetExtension(file.FileName).ToLower(); if (ext == ".png" || ext == ".jpg" || ext == ".jpeg" || ext == ".gif") { try { var imgPath = "/content/attachments/" + house.title; var dirPath = HttpContext.Server.MapPath("~" + imgPath); Directory.CreateDirectory(dirPath); newTransaction.receiptType = ext; newTransaction.receiptUrl = Path.Combine(imgPath, file.FileName); newTransaction.receiptName = file.FileName; file.SaveAs(Path.Combine(dirPath, file.FileName)); db.Transactions.Add(newTransaction); db.SaveChanges(); return(Json(new { success = true, text = "Transaction Added!" }, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { return(Json(new { success = false, rtext = "Transaction failed! Please try again." }, JsonRequestBehavior.AllowGet)); } } } db.Transactions.Add(newTransaction); db.SaveChanges(); return(Json(new { success = true, text = "Transaction Added!" }, JsonRequestBehavior.AllowGet)); //[Bind(Include = "description,amount,date,bankAcctId,transactionCatagoryId,transactionTypeId")] Transaction transaction, HttpPostedFileBase fileInput //if (ModelState.IsValid){ } return(Json(new { success = false, text = "Transaction failed! Please try again." }, JsonRequestBehavior.AllowGet)); }
public static void Main(string[] Args) { Console.WriteLine("------------------------------------------------------"); Console.WriteLine("Executing Sample from File: DOSale_ACH.cs"); Console.WriteLine("------------------------------------------------------"); // Create the Data Objects. // Create the User data object with the required user details. UserInfo User = new UserInfo("<user>", "<vendor>", "<partner>", "<password>"); // Create the Payflow Connection data object with the required connection details. // The PAYFLOW_HOST property is defined in the App config file. PayflowConnectionData Connection = new PayflowConnectionData(); // Create a new Invoice data object with the Amount, Billing Address etc. details. Invoice Inv = new Invoice(); // Set Amount. Currency Amt = new Currency(new decimal(25.12)); Inv.Amt = Amt; Inv.PoNum = "PO12345"; Inv.InvNum = "INV12345"; // Set the Billing Address details. BillTo Bill = new BillTo(); Bill.BillToStreet = "123 Main St."; Bill.BillToZip = "12345"; Inv.BillTo = Bill; // Create a new Payment Device - Bank Account data object. // The input parameters are Account No. and ABA. BankAcct BA = new BankAcct("1111111111", "111111118"); // The Account Type can be "C" for Checking and "S" for Saving. BA.AcctType = "C"; BA.Name = "John Doe"; // Create a new Tender - ACH Tender data object. ACHTender ACH = new ACHTender(BA); ACH.AuthType = "WEB"; // Sending as a Web transaction. ACH.ChkNum = "1234"; // Create a new ACH - Sale Transaction. SaleTransaction Trans = new SaleTransaction(User, Connection, Inv, ACH, PayflowUtility.RequestId); // Setting verbosity to HIGH to get full response. Trans.Verbosity = "HIGH"; // Submit the Transaction Response Resp = Trans.SubmitTransaction(); // Display the transaction response parameters. if (Resp != null) { // Get the Transaction Response parameters. TransactionResponse TrxnResponse = Resp.TransactionResponse; if (TrxnResponse != null) { Console.WriteLine("RESULT = " + TrxnResponse.Result); Console.WriteLine("PNREF = " + TrxnResponse.Pnref); Console.WriteLine("RESPMSG = " + TrxnResponse.RespMsg); Console.WriteLine("HOSTCODE = " + TrxnResponse.HostCode); Console.WriteLine("TRANSTIME = " + TrxnResponse.TransTime); Console.WriteLine("CHECK NAME (FIRSTNAME) = " + TrxnResponse.FirstName); Console.WriteLine("AMOUNT = " + TrxnResponse.Amt); Console.WriteLine("ACCT = " + TrxnResponse.Acct); } // Display the response. Console.WriteLine(Environment.NewLine + PayflowUtility.GetStatus(Resp)); // Get the Transaction Context and check for any contained SDK specific errors (optional code). Context TransCtx = Resp.TransactionContext; if (TransCtx != null && TransCtx.getErrorCount() > 0) { Console.WriteLine(Environment.NewLine + "Transaction Errors = " + TransCtx.ToString()); } } Console.WriteLine("Press Enter to Exit ..."); Console.ReadLine(); }