public ActionResult Create(SilverState silverstate) { if (ModelState.IsValid) { db.AccountStates.Add(silverstate); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(silverstate)); }
public ActionResult Create(NextSavingAccount nextsavingaccount) { if (ModelState.IsValid) { db.NextSavingAccounts.Add(nextsavingaccount); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(nextsavingaccount)); }
public ActionResult Create(Payee payee) { if (ModelState.IsValid) { db.Payees.Add(payee); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(payee)); }
public ActionResult Create(NextTransactionNumber nexttransactionnumber) { if (ModelState.IsValid) { db.NextTransactionNumbers.Add(nexttransactionnumber); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(nexttransactionnumber)); }
public ActionResult Create(BronzeState bronzestate) { if (ModelState.IsValid) { db.AccountStates.Add(bronzestate); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(bronzestate)); }
public ActionResult Create(TransactionType transactiontype) { if (ModelState.IsValid) { db.TransactionTypes.Add(transactiontype); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(transactiontype)); }
public ActionResult Create(Institution institution) { if (ModelState.IsValid) { db.Institutions.Add(institution); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(institution)); }
public ActionResult Create(PlatinumState platinumstate) { if (ModelState.IsValid) { db.AccountStates.Add(platinumstate); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(platinumstate)); }
public ActionResult Create(Client client) { client.SetNextClientNumber(); if (ModelState.IsValid) { db.Clients.Add(client); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(client)); }
public ActionResult Create(RFIDTag rfidtag) { if (ModelState.IsValid) { db.RFIDTags.Add(rfidtag); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.ClientId = new SelectList(db.Clients, "ClientId", "FirstName", rfidtag.ClientId); return(View(rfidtag)); }
public ActionResult Create(Transaction transaction) { transaction.SetNextTransactionNumber(); if (ModelState.IsValid) { db.Transactions.Add(transaction); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.BankAccountId = new SelectList(db.BankAccounts, "BankAccountId", "Notes", transaction.BankAccountId); ViewBag.TransactionTypeId = new SelectList(db.TransactionTypes, "TransactionTypeId", "Description", transaction.TransactionTypeId); return(View(transaction)); }
/// <summary> /// Represent calculate interest web service /// </summary> /// <param name="accountId"></param> /// <param name="notes"></param> /// <returns></returns> public double?CalculateInterest(int accountId, string notes) { BankAccount bankAccount = db.BankAccounts.Where(x => x.BankAccountId == accountId).SingleOrDefault(); AccountState state = db.AccountStates.Where(x => x.AccountStateId == bankAccount.AccountStateId).SingleOrDefault(); double rate = state.RateAdjustment(bankAccount); double interest = (rate * bankAccount.Balance) / 12; bankAccount.Balance += interest; db.SaveChanges(); TransactionRecord(accountId, (int)TransactionTypeValues.CalculateInterest, interest, notes); return(bankAccount.Balance); }
public ActionResult Create(ChequingAccount chequingaccount) { chequingaccount.SetNextAccountNumber(); if (ModelState.IsValid) { db.BankAccounts.Add(chequingaccount); db.SaveChanges(); chequingaccount.ChangeState(); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.AccountStateId = new SelectList(db.AccountStates, "AccountStateId", "Description", chequingaccount.AccountStateId); ViewBag.ClientId = new SelectList(db.Clients, "ClientId", "FullName", chequingaccount.ClientId); return(View(chequingaccount)); }
/// <summary> /// Record the transaction and to the database /// </summary> /// <param name="accountId">the account id</param> /// <param name="transactionTypeId">the id of the transaction type</param> /// <param name="amount">amount associated with the transaction</param> /// <param name="notes">note made with the transaction</param> private static void TransactionRecord(int accountId, int transactionTypeId, double amount, string notes) { BankOfBIT_XWContext db = new BankOfBIT_XWContext(); if (transactionTypeId == (int)TransactionTypeValues.Deposit || transactionTypeId == (int)TransactionTypeValues.TransferRecipient) { Transaction transaction = new Transaction(); transaction.BankAccountId = accountId; transaction.TransactionTypeId = transactionTypeId; transaction.Deposit = amount; transaction.Withdrawal = 0; transaction.DateCreated = DateTime.Today; transaction.Notes = notes; db.Transactions.Add(transaction); } if (transactionTypeId == (int)TransactionTypeValues.Withdrawal || transactionTypeId == (int)TransactionTypeValues.BillPayment || transactionTypeId == (int)TransactionTypeValues.Transfer) { Transaction transaction = new Transaction(); transaction.BankAccountId = accountId; transaction.TransactionTypeId = transactionTypeId; transaction.Withdrawal = amount; transaction.Deposit = 0; transaction.DateCreated = DateTime.Today; transaction.Notes = notes; db.Transactions.Add(transaction); } if (transactionTypeId == (int)TransactionTypeValues.CalculateInterest) { if (amount > 0) { Transaction transaction = new Transaction(); transaction.BankAccountId = accountId; transaction.TransactionTypeId = transactionTypeId; transaction.Deposit = amount; transaction.Withdrawal = 0; transaction.DateCreated = DateTime.Today; transaction.Notes = notes; db.Transactions.Add(transaction); } if (amount < 0) { Transaction transaction = new Transaction(); transaction.BankAccountId = accountId; transaction.TransactionTypeId = transactionTypeId; transaction.Withdrawal = System.Math.Abs(amount); transaction.Deposit = 0; transaction.DateCreated = DateTime.Today; transaction.Notes = notes; db.Transactions.Add(transaction); } } db.SaveChanges(); }
// PUT api/AccountState/5 public HttpResponseMessage PutAccountState(int id, AccountState accountstate) { if (ModelState.IsValid && id == accountstate.AccountStateId) { db.Entry(accountstate).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { return(Request.CreateResponse(HttpStatusCode.NotFound)); } return(Request.CreateResponse(HttpStatusCode.OK)); } else { return(Request.CreateResponse(HttpStatusCode.BadRequest)); } }