public async Task <IActionResult> Withdraw(int id, int amount) { try { Business business = new Business(); business = await _context.Business.FirstOrDefaultAsync(c => c.accountNumber == id); var newBalance = (business.Balance - amount); business.Balance = newBalance; Transaction transaction = new Transaction(); transaction.accountNumber = id; transaction.accountType = "business"; transaction.amount = amount; transaction.date = DateTime.Now; transaction.type = "withdraw"; _context.Update(business); await _context.SaveChangesAsync(); //_context.Update(transaction); //await _context.SaveChangesAsync(); } catch { ViewData["ErrorMessage"] = "There was a problem with your withdrawl please try again"; return(View()); } return(RedirectToAction(nameof(Business))); }
public async Task <IActionResult> Withdraw(int id, int amount) { Term term = new Term(); term = await _context.Term.FirstOrDefaultAsync(c => c.accountNumber == id); DateTime expdate = term.createdAt.AddMonths(term.period); if (DateTime.Today == expdate) { if (term.Balance >= amount) { try { var newBalance = (term.Balance - amount); term.Balance = newBalance; _context.Update(term); await _context.SaveChangesAsync(); Transaction transaction = new Transaction(); transaction.accountNumber = id; transaction.accountType = "Term Deposits"; transaction.amount = amount; transaction.date = DateTime.Now; transaction.type = "Withdraw"; transaction.balance = newBalance; _context.Update(transaction); await _context.SaveChangesAsync(); } catch { ViewData["ErrorMessage"] = "There was a problem with your withdrawl please try again"; return(View()); } return(RedirectToAction(nameof(ViewTerms))); } else { ViewData["ErrorMessage"] = "Your Balance is not sufficent to do transactions."; return(View()); } } else { ViewData["ErrorMessage"] = "You can't withdraw before mature."; return(View()); } }
public int Update(int id, Customer customer) { _context.Update(customer); _context.SaveChanges(); return(id); }
public int Update(int id, BillPay billPay) { _context.Update(billPay); _context.SaveChanges(); return(id); }
public async Task <IActionResult> Edit(int id, [Bind("Id,Name,SSN")] Account account) { if (id != account.Id) { return(NotFound()); } if (ModelState.IsValid) { using (var context = new BankContext()) { try { context.Update(account); await context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!AccountExists(context, account.Id)) { return(NotFound()); } else { throw; } } } return(RedirectToAction(nameof(Index))); } return(View(account)); }
public async Task <IActionResult> Edit(int id, [Bind("Id,accountNumber,numberOfMonth,accountType,amount,date,type,CustomerId")] Transaction transaction) { if (id != transaction.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(transaction); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TransactionExists(transaction.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(DisplayRecord))); } ViewData["CustomerId"] = new SelectList(_context.Customers, "Id", "Id", transaction.CustomerId); return(View(transaction)); }
public async Task <IActionResult> Edit(int id, [Bind("AccountNumber,EmailAddress,Balance,AccountType,CreatedDate")] Account account) { if (id != account.AccountNumber) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(account); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!AccountExists(account.AccountNumber)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(account)); }
public async Task <IActionResult> Edit(int id, [Bind("Id,accountNumber,numberOfMonth,accountType,amount,date,type")] Transaction transaction) { if (id != transaction.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(transaction); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TransactionExists(transaction.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(transaction)); }
public async Task <IActionResult> Edit(int id, [Bind("Id,registerId,firstName,lastName")] Customers customers) { if (id != customers.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(customers); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CustomersExists(customers.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(customers)); }
public int Update(int id, BaseAccount account) { _context.Update(account); _context.SaveChanges(); return(id); }
public async Task <IActionResult> EditTemplate(int id, Template template) { if (ModelState.IsValid) { Template t = await _context.Template.AsNoTracking().FirstOrDefaultAsync(e => e.Id == id); if (!_context.IsTemplateNameUnique(template.Name, t.Id) && template.Name != t.Name) { ViewBag.ErrName = "Template name must be unique."; return(View(template)); } template.UserId = t.UserId; try { _context.Update(template); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(TemplateList))); } catch { return(Redirect("/Home/Error")); } } else { return(View(template)); } }
public async Task <IActionResult> Edit(long id, [Bind("PosId,PosName,Salary,Responsibilities,Requirements")] Positions positions) { if (id != positions.PosId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(positions); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PositionsExists(positions.PosId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(positions)); }
public async Task <IActionResult> Edit(int id, [Bind("type,accountNumber,InterestRate,Balance,createdAt")] Loan loan) { if (id != loan.accountNumber) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(loan); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!LoanExists(loan.accountNumber)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(loan)); }
public int Update(int id, Transaction transaction) { _context.Update(transaction); _context.SaveChanges(); return(id); }
public async Task TestEditTemplate() { temp.Name = "Temp2"; _context.Update(temp); await _context.SaveChangesAsync(); Assert.IsTrue(await _context.Template.AnyAsync(a => a.Name == "Temp2")); }
public async Task TestEditUser() { user.Name = "Venca"; _context.Update(user); await _context.SaveChangesAsync(); Assert.IsTrue(await _context.User.AnyAsync(a => a.Name == "Venca")); }
public async Task <IActionResult> Payment(int id, int amount) { if (amount > 0) { try { Loan loan = new Loan(); loan = await _context.Loan.FirstOrDefaultAsync(c => c.accountNumber == id); if (loan.Balance == 0 - amount) { var newBalance = (loan.Balance + amount); loan.Balance = newBalance; _context.Update(loan); await _context.SaveChangesAsync(); Transaction transaction = new Transaction(); transaction.accountNumber = id; transaction.accountType = "Loan"; transaction.amount = amount; transaction.date = DateTime.Now; transaction.type = "Deposit"; transaction.balance = newBalance; _context.Update(transaction); await _context.SaveChangesAsync(); } } catch { ViewData["ErrorMessage"] = "There was a problem with your Transaction."; return(View()); } } else { ViewData["ErrorMessage"] = "No Negative amount..........."; return(View()); } return(RedirectToAction(nameof(CustomLoan))); }
public async Task <bool> Update(Customer customer) { _context.Update(customer); //Change Tracker : only change the state var success = await _context.SaveChangesAsync(); if (success == 0) { return(false); } return(true); }
public async Task <bool> Update(Account account) { _context.Update(account); //Change Tracker : only change the state try { await _context.SaveChangesAsync(); } catch (Exception ex) { } return(true); }
public async Task <IActionResult> Edit(int id, [Bind("Id,Name,BirthNumber,Adress,Email,Phone,AccountNumber,CardNumber,Money,Login,Pin,Role")] User user) { if (id != user.Id) { return(Redirect("/Authorization/Unauth")); } if (ModelState.IsValid) { try { _context.Update(user); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!UserExists(user.Id)) { return(Redirect("/User/UNotFound")); } else { return(Redirect("/Home/Error")); } } string userId = HttpContext.Session.GetString("UserId"); SessionHandler.SetUser(userId, user); return(RedirectToAction(nameof(Index))); } else { ViewBag.ErrMsg = "Values are not valid."; return(View(user)); } }
public async Task <IActionResult> PutCustomer([FromRoute] long id, [FromBody] Customer customer) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var _customer = await _context.Customers.FindAsync(id); if (_customer == null) { return(NotFound()); } _customer.FirstName = customer.FirstName; _customer.LastName = customer.LastName; _context.Update(_customer); await _context.SaveChangesAsync(); return(NoContent()); }
public void Update(Currencies currencies) { _context.Update(currencies); }
public async Task <IActionResult> EditUser(int id, [Bind("Id,Name,BirthNumber,Adress,Email,Phone,AccountNumber,CardNumber,Money,Login,Pin,Role")] User user, [Bind("CardGen")] bool CardGen) { if (id != user.Id) { return(RedirectToAction(nameof(Index))); } User u = await _context.User.AsNoTracking().FirstOrDefaultAsync(e => e.Id == id); if (user.Role == Role.User) { if (CardGen) { user.CardNumber = _context.GenerateCardNumber(); } if (user.CardNumber == null) { ViewBag.ErrAcc = "Card number is required"; return(View(user)); } if (!_context.IsCardUnique((long)user.CardNumber) && user.CardNumber != u.CardNumber) { ViewBag.ErrCard = "Card number is not unique."; return(View(user)); } if (user.Money == null) { user.Money = 0; } } if (ModelState.IsValid) { try { _context.Update(user); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!UserExists(user.Id)) { return(Redirect("/User/UNotFound")); } else { return(Redirect("/Home/Error")); } } MailClient.Singleton.SendEditUser(user); return(RedirectToAction(nameof(Index))); } else { ViewBag.ErrMsg = "Values are not valid."; return(View(user)); } }
public void Update(TransactionHistories transaction_histories) { _context.Update(transaction_histories); }
public async Task <IActionResult> Deposit(int id, double amount) { if (amount > 0) { try { Checking checking = new Checking(); checking = await _context.Checking.FirstOrDefaultAsync(c => c.accountNumber == id); var newBalance = (checking.Balance + amount); checking.Balance = newBalance; _context.Update(checking); await _context.SaveChangesAsync(); Transaction transaction = new Transaction(); transaction.accountNumber = id; transaction.accountType = "Checking"; transaction.amount = amount; transaction.date = DateTime.Now; transaction.type = "Deposit"; //_context.Update(checking); //await _context.SaveChangesAsync(); _context.Update(transaction); await _context.SaveChangesAsync(); } catch { ViewData["ErrorMessage"] = "There was a problem with your deposit please try again"; return(View()); } return(RedirectToAction(nameof(Index)));//Nav to the Home } else { ViewData["ErrorMessage"] = "Please insert positive value"; return(View()); } }
public void Update(CurrencyExchange currency_exchange) { _context.Update(currency_exchange); }
public void Update(Users user) { _context.Update(user); }
public async Task <IActionResult> Deposit(int id, double amount) { if (amount > 0) { try { Business business = new Business(); business = await _context.Business.FirstOrDefaultAsync(c => c.accountNumber == id); var newBalance = (business.Balance + amount); business.Balance = newBalance; _context.Update(business); await _context.SaveChangesAsync(); Transaction transaction = new Transaction(); transaction.accountNumber = id; transaction.accountType = "Business"; transaction.amount = amount; transaction.date = DateTime.Now; transaction.type = "Deposit"; transaction.balance = business.Balance; _context.Update(transaction); await _context.SaveChangesAsync(); } catch { ViewData["ErrorMessage"] = "There was a problem with your transaction please try again"; return(View()); } return(RedirectToAction(nameof(BusinessView))); } else { ViewData["ErrorMessage"] = "There was a problem with your transaction please try again"; return(View()); } }
public void Update(Operations operation) { _context.Update(operation); }
public void Update(BankTotalBalance bank_total_balance) { _context.Update(bank_total_balance); }