public async Task <AccountLoan> Create(AccountLoan accountLoan) { _context.AccountLoans.Add(accountLoan); await _context.SaveChangesAsync(); return(accountLoan); }
public async Task <Account> Create(Account model) { _context.Accounts.Add(model); await _context.SaveChangesAsync(); return(model); }
public async Task <IActionResult> Put(CustomerDto customer) { // If the caller doesnt provide id we try getting it from claims customer.Id ??= User.Claims.FirstOrDefault(c => c.Type.Equals(JwtClaimTypes.Name))?.Value; if (customer.Id == null) { logger.LogDebug("No id provided or found for the User"); return(BadRequest("No Id provided")); } var dbCustomer = await dbContext.Customers.FindAsync(customer.Id); if (dbCustomer == null) { logger.LogDebug($"No Customer found in db for id: {customer.Id}"); return(NotFound("Customer not found")); } dbContext.Attach(dbCustomer); dbCustomer.RegistrationNumber = customer.RegistrationNumber; await dbContext.SaveChangesAsync(); logger.LogDebug($"Customer updated with id: {customer.Id}"); return(Ok(dbCustomer)); }
public async Task <CountersReport> Create(CountersReport countersReport) { _context.CountersReports.Add(countersReport); await _context.SaveChangesAsync(); return(countersReport); }
public async Task <bool> Create(Customer customer) { _context.Add(customer); await _context.SaveChangesAsync(); return(true); }
public async Task <ServiceResponse <AccountBalance> > AddAmount(AccountBalance accountBalance) { try { accountBalance.AccountBalanceId = 0; //Identity column //Adding data into transaction table to capture transaction history TransactionAudit audit = new TransactionAudit(); audit.ActionId = 1; // FirstTime Add Amount audit.CustomerId = accountBalance.CustomerId; audit.Balance = accountBalance.Balance; audit.CreatedDate = DateTime.Now; await _bankDbContext.TransactionAudits.AddAsync(audit); await _bankDbContext.AccountBalances.AddAsync(accountBalance); await _bankDbContext.SaveChangesAsync(); serviceResponse.Data = accountBalance; serviceResponse.Message = $"First time amount added successfully...Balance is {accountBalance.Balance}"; return(serviceResponse); } catch (Exception ex) { serviceResponse.Success = false; serviceResponse.Message = ex.Message; return(serviceResponse); } }
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 <LoginReport> Create(LoginReport loginReport) { _context.LoginReports.Add(loginReport); await _context.SaveChangesAsync(); return(loginReport); }
public async Task <UserInfo> Create(UserInfo model) { _context.UserInfos.Add(model); await _context.SaveChangesAsync(); return(model); }
public async Task <FiltersReport> Create(FiltersReport filtersReport) { _context.FiltersReports.Add(filtersReport); await _context.SaveChangesAsync(); return(filtersReport); }
public async Task <IActionResult> PutBank([FromRoute] int id, [FromBody] Bank bank) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != bank.BankID) { return(BadRequest()); } _context.Entry(bank).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!BankExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutUser(int id, User user) { if (id != user.Id) { return(BadRequest()); } _context.Entry(user).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!UserExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <TransfersReport> Create(TransfersReport transfersReport) { _context.TransfersReports.Add(transfersReport); await _context.SaveChangesAsync(); return(transfersReport); }
public async Task <TransactionsHistory> Create(TransactionsHistory model) { _context.TransactionsHistories.Add(model); await _context.SaveChangesAsync(); return(model); }
public async Task <Loan> Create(Loan loan) { _context.Loans.Add(loan); await _context.SaveChangesAsync(); return(loan); }
public async Task <Card> Create(Card card) { _context.Cards.Add(card); await _context.SaveChangesAsync(); return(card); }
public async Task <AccountDeposit> Create(AccountDeposit accountDeposit) { _context.UserDeposits.Add(accountDeposit); await _context.SaveChangesAsync(); return(accountDeposit); }
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> 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("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("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("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("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 <Card> ApproveCard(int id, Card card) { var getCard = await GetById(id); getCard.Status = CardStatus.Active.ToString(); getCard.ExpireDate = card.ExpireDate; getCard.CCV = card.CCV; getCard.CardNumber = card.CardNumber; getCard.CreatedAt = DateTime.Now; await Update(getCard); await _context.SaveChangesAsync(); return(card); }
public async Task <IActionResult> Deposits(float amount) { var user = await _userManager.GetUserAsync(HttpContext.User); //Current logged user var natural = await GetNaturalAsync(user.Id); if (natural != null) { natural.SavingAccounts[DefaultAccount].Amount += amount; var depositCertificate = new DepositCertificate { Amount = amount, Balance = natural.SavingAccounts[DefaultAccount].Amount, Currency = "US Dollar", DateHour = DateTime.Now.ToString("f"), SavingAccountId = natural.SavingAccounts[DefaultAccount].Id }; await _dbContext.DepositCertificates.AddAsync(depositCertificate); await _dbContext.SaveChangesAsync(); return(View("Natural", natural)); // return LocalRedirect(returnUrl); } var juridic = await GetJuridicAsync(user.Id); if (juridic != null) { juridic.SavingAccounts[DefaultAccount].Amount += amount; var depositCertificate = new DepositCertificate { Amount = amount, Balance = juridic.SavingAccounts[DefaultAccount].Amount, Currency = "US Dollar", DateHour = DateTime.Now.ToString("f"), SavingAccountId = juridic.SavingAccounts[DefaultAccount].Id }; await _dbContext.DepositCertificates.AddAsync(depositCertificate); await _dbContext.SaveChangesAsync(); return(View("Juridic", juridic)); // return LocalRedirect(returnUrl); } return(NotFound()); }
public async Task <ActionResult> Create(Transfer transfer, CancellationToken cancellationToken = default) { var fromBankAccount = await _dbContext.BankAccounts.FindAsync(transfer.FromBankAccountId); var toBankAccount = await _dbContext.BankAccounts.FindAsync(transfer.ToBankAccountId); if (fromBankAccount == null) { return(BadRequest($"Bank account does not exist {transfer.FromBankAccountId}")); } if (toBankAccount == null) { return(BadRequest($"Bank account does not exist {transfer.ToBankAccountId}")); } if (fromBankAccount.HasFunds(transfer.Amount)) { await _dbContext.Transfers.AddAsync(transfer, cancellationToken); fromBankAccount.WithdrawFunds(transfer.Amount); toBankAccount.DepositFunds(transfer.Amount); await _dbContext.SaveChangesAsync(cancellationToken); } else { return(BadRequest("Insufficient funds")); } return(CreatedAtAction(nameof(Get), new { id = transfer.Id }, transfer)); }
public async Task <string> Get1() { var dbconnect = _aplloDbContext.Database.GetDbConnection(); BankDbContext bankDb = new BankDbContext(new DbContextOptionsBuilder <BankDbContext>().UseNpgsql(dbconnect).Options); using (var transcation = await _aplloDbContext.Database.BeginTransactionAsync()) { await _aplloDbContext.AddAsync(new TestApllo { Name = "2222撒大声地" }); await _aplloDbContext.SaveChangesAsync(); bankDb.Database.UseTransaction(transcation.GetDbTransaction()); await bankDb.AddAsync(new TestBank { Name = "444444sdsd" }); await bankDb.SaveChangesAsync(); await transcation.CommitAsync(); } return("2"); }
protected override Task Handle(CalculateIncomeCommand request, CancellationToken cancellationToken) { var accounts = this._context.Accounts.ToArray(); _yieldService.CalculateInterestFor(request.ForDate, accounts, request.InterestRate, cancellationToken, days: 1); _context.SaveChangesAsync(cancellationToken); return(Task.CompletedTask); }