public virtual void Delete(TEntity entityToDelete) { if (context.Entry(entityToDelete).State == EntityState.Detached) { dbSet.Attach(entityToDelete); } dbSet.Remove(entityToDelete); }
public ActionResult Edit([Bind(Include = "cust_id,cust_name,Dob,contact_no,cust_add,a_c_no,a_c_type,Bal,card_no,card_pin,b_branch_id")] Customer customer) { if (ModelState.IsValid) { db.Entry(customer).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } bool select1, select2; if (customer.a_c_type == "debit") { select1 = true; select2 = false; } else { select1 = false; select2 = true; } ViewBag.b_branch_id = new SelectList(db.Banks, "b_branch_id", "b_branch_name", customer.b_branch_id); ViewBag.a_c_type = new SelectList( new List <SelectListItem> { new SelectListItem { Selected = select1, Text = "debit", Value = "debit" }, new SelectListItem { Selected = select2, Text = "credit", Value = "credit" } }, "Value", "Text"); return(View(customer)); }
public async Task <ResponseModel> Transfer([FromBody] RequestModel requestModel) { //performs validation on request's data //get merchant account details from database var account = new Account(); using (BankEntities db = new BankEntities()) { account = await db.Accounts.FindAsync(requestModel.MerchantAccountID); } //check if account exists if (account == null) { return(new ResponseModel(ResponseStatuses.Error, "Invalid Merchant account ID")); } /* * contact issuing bank to request money transfer * check if response from issuing bank is as expected and return appropriate response to this caller */ //if everything is as expected: //update account balance using (BankEntities db = new BankEntities()) { account.Amount += requestModel.Amount; db.Entry(account).State = EntityState.Modified; await db.SaveChangesAsync(); } //return successful response return(new ResponseModel(ResponseStatuses.Successful, string.Empty)); }
public ActionResult Edit([Bind(Include = "AccountNumber,AccountName,Balance,IBAN")] Account account) { if (ModelState.IsValid) { db.Entry(account).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(account)); }
public ActionResult Edit([Bind(Include = "DepositID,Depositnumber,DepositAmount")] Deposit deposit) { if (ModelState.IsValid) { db.Entry(deposit).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.Depositnumber = new SelectList(db.Accounts, "AccountNumber", "AccountName", deposit.Depositnumber); return(View(deposit)); }
public ActionResult Edit([Bind(Include = "a_branch_id,a_branch_name,a_branch_add,a_admin_id,available_cash,b_branch_id")] ATM aTM) { if (ModelState.IsValid) { db.Entry(aTM).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.a_admin_id = new SelectList(db.A_ATM, "a_admin_id", "a_admin_name", aTM.a_admin_id); ViewBag.b_branch_id = new SelectList(db.Banks, "b_branch_id", "b_branch_name", aTM.b_branch_id); return(View(aTM)); }
public ActionResult Edit([Bind(Include = "TransferID,TransferFrom,TranferMoney,TransferTo")] Transfer transfer) { if (ModelState.IsValid) { db.Entry(transfer).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.TransferFrom = new SelectList(db.Accounts, "AccountNumber", "AccountName", transfer.TransferFrom); ViewBag.TransferTo = new SelectList(db.Accounts, "AccountNumber", "AccountName", transfer.TransferTo); return(View(transfer)); }