public async Task <IActionResult> Create(BillPay billPay) { if (ModelState.IsValid) { if (_context.Account.Where(x => x.AccountNumber == billPay.AccountNumber).FirstOrDefault().Balance > billPay.Amount && billPay.Amount > 0) { if (billPay.ScheduleDate < Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd"))) { ModelState.AddModelError(nameof(billPay.ScheduleDate), "Invaild data time."); } else { ViewData["ErrorMessage"] = ""; billPay.ModifyDate = DateTime.UtcNow; billPay.Status = BillPayStatus.Available; _context.Add(billPay); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } } else { ModelState.AddModelError(nameof(billPay.Amount), "Not enough money or invaild amount."); } } ViewData["AccountNumber"] = new SelectList(_context.Account.Where(a => a.CustomerID == CustomerID), "AccountNumber", "AccountNumber"); ViewData["PayeeID"] = new SelectList(_context.Payee.Where(x => x.PayeeID > 0), "PayeeID", "PayeeName"); return(View(billPay)); }
public async Task <bool> Create(Customer customer) { _context.Add(customer); await _context.SaveChangesAsync(); return(true); }
public T Add(T itemToAdd) { var entity = dbContext.Add <T>(itemToAdd); dbContext.SaveChanges(); return(entity.Entity); }
public async Task <IActionResult> Create([Bind("AccountNumber,Name,DOB,PhoneNo,Address,City,ZipCode,State,OpeningDate,Balance")] Account _account) { if (ModelState.IsValid) { _context.Add(_account); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(_account)); }
public async Task <IActionResult> Deposit(int id, [Bind("TranId,amount,date,TranscationType, account")] Transaction transaction) { var account = _context.Accounts.FirstOrDefault(m => m.AccountNumber == id); //account.Balance += transaction.amount; transaction.account = account; transaction.date = DateTime.Now; transaction.TranscationType = "Deposit"; if (ModelState.IsValid && account.Deposit(transaction.amount) && account.IsActive) { _context.Add(transaction); _context.Update(account); await _context.SaveChangesAsync(); return(RedirectToAction("../Accounts/Index")); } ViewBagInfo(id); ViewBag.ErrorMessage = "Invalid operation! Check the amount or your account status."; return(View(transaction)); }
public async Task <IActionResult> Create([Bind("Id,firstName,lastName,email,phoneNumber,address")] Customer customer) { if (ModelState.IsValid) { _context.Add(customer); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(customer)); }
public async Task <IActionResult> Create([Bind("AccountNumber,Balance,InterestRate,IsActive")] Account account) { if (ModelState.IsValid) { _context.Add(account); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(account)); }
public async Task <IActionResult> Create([Bind("Id,type,accountNumber,CustomerId,InterestRate,Balance,createdAt,status,period,dateAndTime")] Saving saving) { if (ModelState.IsValid) { _context.Add(saving); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["CustomerId"] = new SelectList(_context.Customer, "Id", "Id", saving.CustomerId); return(View(saving)); }
public async Task <IActionResult> Create([Bind("Id,OwnerId,type,Amount")] Account account) { account.type = Account.Types.Checking; account.OwnerId = _userManager.GetUserId(User); if (ModelState.IsValid) { _context.Add(account); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(account)); }
public async Task <IActionResult> Create([Bind("Maturity,Id,OwnerId,type,Amount")] TermDepositAccount termDepositAccount) { termDepositAccount.type = Account.Types.TermDeposit; termDepositAccount.OwnerId = _userManager.GetUserId(User); if (ModelState.IsValid) { _context.Add(termDepositAccount); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(termDepositAccount)); }
public async Task <IActionResult> Create([Bind("Overdraft,OverdraftCost,OverdraftDueDate,Id,OwnerId,type,Amount")] BusinessAccount businessAccount) { businessAccount.type = Account.Types.Business; businessAccount.OwnerId = _userManager.GetUserId(User); if (ModelState.IsValid) { _context.Add(businessAccount); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(businessAccount)); }
public async Task <IActionResult> Create([Bind("MonthlyDue,Id,OwnerId,type,Amount")] LoanAccount loanAccount) { loanAccount.type = Account.Types.Loan; loanAccount.OwnerId = _userManager.GetUserId(User); loanAccount.MonthlyDue = loanAccount.Amount / 24; if (ModelState.IsValid) { _context.Add(loanAccount); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(loanAccount)); }
public async Task <IActionResult> Create([Bind("Id,FirstName,LastName,Address,UserRef,Age")] Customer customer) { if (ModelState.IsValid) { var user = await _context.Users.FirstOrDefaultAsync(m => m.UserName == HttpContext.User.Identity.Name); customer.UserRef = user.Id; _context.Add(customer); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["UserRef"] = new SelectList(_context.Set <User>(), "Id", "Id", customer.UserRef); return(View(customer)); }
public async Task <IActionResult> Create(BillPay billPay) { //Model verification if (ModelState.IsValid) { //Determine the transfer amount if (_context.Account.Where(x => x.AccountNumber == billPay.AccountNumber).FirstOrDefault().Balance > billPay.Amount && billPay.Amount > 0) { //Determine date if (billPay.ScheduleDate < Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd"))) { ModelState.AddModelError(nameof(billPay.ScheduleDate), "Invaild data time."); } else { //Add billpay to the database billPay.ModifyDate = DateTime.UtcNow; billPay.Status = BillPayStatus.Available; _context.Add(billPay); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } } else { ModelState.AddModelError(nameof(billPay.Amount), "Not enough money or invaild amount."); } } var user = await _userManager.GetUserAsync(User); var CustomerID = user.CustomerID.Value; ViewData["AccountNumber"] = new SelectList(_context.Account.Where(a => a.CustomerID == CustomerID), "AccountNumber", "AccountNumber"); ViewData["PayeeID"] = new SelectList(_context.Payee.Where(x => x.PayeeID > 0), "PayeeID", "PayeeName"); return(View(billPay)); }