/// <summary> /// Get action for "_TransactionHistory" partial view. /// </summary> /// <param name="model"></param> /// <returns></returns> public PartialViewResult CurrentUser_TransactionHistory(UserViewModel model) { try { int?Id = SessionState.Current.CurrentAccountId; UserViewModel myTransactions = new UserViewModel(); CurrentAccount current = db.CurrentAccount.FirstOrDefault(user => user.Id == Id); // Mapping Transactions data to a list. // Where the transaction source OR transaction target is the Current User. myTransactions.Transactions.DefaultRow = db.Transaction.Where(usr => usr.To == current.Id | current.Id == usr.From) .Select(row => new UserTransactionResultRowData { TransactionAmount = row.Amount, TransactionDueDate = row.DueDate, TransactionToAccount = row.ToAccount.AccountNumber, TransactionFromAccount = row.FromAccount.AccountNumber, TransactionStartDate = row.Date, TransactionDescription = row.Description }).ToList(); return(PartialView("_TransactionHistory", myTransactions)); } catch (Exception ex) { throw ex; } }
public void WithdrawIntoMinimumBalance() { BankPolicy.minimumcurrentBalance = 5000; Account account = new CurrentAccount("Customer", "000000", 11000); account.makeWithdrawal("000000", 13500); }
static void Main() { IAccount vGoldAccount = new GoldAccount(); IAccount vSaverAccount = new SaverAccount(); ITransferAccount vCurAccount = new CurrentAccount(); vGoldAccount.Credit(10000); vSaverAccount.Credit(100); Console.WriteLine($"Gold Account Balance {vGoldAccount.Balance,6:C}"); Console.WriteLine(vSaverAccount.ToString()); vSaverAccount.Debit(1000); IAccount[] allAccounts = new IAccount[2]; allAccounts[0] = vGoldAccount; allAccounts[1] = vSaverAccount; //Dividend... foreach (IAccount Acc in allAccounts) { Acc.Credit(10); } vCurAccount.Transfer(vSaverAccount, vCurAccount); }
public ActionResult Add(CurrentAccount current) { current.Status = true; db.CurrentAccounts.Add(current); db.SaveChanges(); return(RedirectToAction("Index")); }
private void Form3_Load(object sender, EventArgs e) { accounts = new Account[10]; accounts[0] = new SavingsAccount { Number = 1, Titular = new Client("João lima", 45) }; accounts[1] = new CurrentAccount { Number = 2, Titular = new Client("Maria Carey", 40) }; accounts[2] = new SavingsAccount { Number = 3, Titular = new Client("Marcela Pam", 25) }; foreach (Account acc in accounts) { comboAccounts.Items.Add(acc.Titular.Name); comboTransfer.Items.Add(acc.Titular.Name); this.accountSize++; } }
public ActionResult CloseAccount(int accountId) { using (var _context = new ApplicationDbContext()) { var account2remove = _context.Accounts.Single(a => a.Id == accountId); if (account2remove is LendingAccount) { if (account2remove.Balance < 0) { return(RedirectToAction("Index", "LoggedIn")); } } if (account2remove is CurrentAccount) { CurrentAccount account = account2remove as CurrentAccount; if (account.HasCard()) { BankCard card = _context.BankCards.Single(c => c.ParentAccount.Id == accountId); _context.BankCards.Remove(card); } } _context.Accounts.Remove(account2remove); _context.SaveChanges(); } return(RedirectToAction("Index", "LoggedIn")); }
/// <summary> /// Create an account for a customer /// </summary> /// <param name="ownerId"></param> /// <param name="accType"></param> /// <returns></returns> public Account CreateAccount(string ownerId, string accType) { Account account; if (accType == "Savings") { account = new Account { CustomerId = ownerId, AccType = "Savings", MinimumBalance = 1000.00m }; //DataStore.accounts.Add(account); _ctx.Accounts.Add(account); _ctx.SaveChanges(); // DataAccess.RegisterAccount(account); return account; } else if (accType == "Current") { account = new CurrentAccount { CustomerId = ownerId, AccType = "Current", MinimumBalance = 0.00m }; //DataStore.accounts.Add(account); _ctx.Accounts.Add(account); var s = _ctx.SaveChanges(); //DataAccess.RegisterAccount(account); return account; } return null; }
private static void Main(string[] args) { CurrentAccount firstAccount = new CurrentAccount(); firstAccount.holder = "Marina Ruy Barbosa"; firstAccount.agencyNumber = 863; firstAccount.accountNumber = 863452; CurrentAccount secondAccount = new CurrentAccount(); secondAccount.holder = "Marina Ruy Barbosa"; secondAccount.agencyNumber = 863; secondAccount.accountNumber = 863452; Console.WriteLine("Reference type equality: [first account x second account] = " + (firstAccount == secondAccount)); int age = 27; int anotherAge = 27; Console.WriteLine("Value type equality: [age x anotherAge] = " + (age == anotherAge)); firstAccount = secondAccount; Console.WriteLine("Reference type equality: [first account = second account] = " + (firstAccount == secondAccount)); firstAccount.bankBalance = 300; Console.WriteLine("The " + firstAccount.holder + " bank balance is R$ " + firstAccount.bankBalance); Console.WriteLine("The " + secondAccount.holder + " bank balance is R$ " + secondAccount.bankBalance); Console.ReadLine(); }
/// <summary> /// Gets personal bank account opening page if the user has a valid ID. /// </summary> /// <param name="Id"></param> /// <returns></returns> public ActionResult PersonalBankAccountOpening(int?Id) { try { var inDB = db.CurrentAccount.Where(hasValue => hasValue.PersonId == null && hasValue.CompanyId == null).FirstOrDefault(usr => usr.Id == Id).Equals(1); if (inDB == false) { PersonRegistrationViewModel personRegistration = new PersonRegistrationViewModel(); try { CurrentAccount dbAcc = db.CurrentAccount.Where(model => model.Id == Id).FirstOrDefault(); personRegistration.PersonalCommonData.AccountNumber = dbAcc.AccountNumber; personRegistration.PersonalCommonData.EmailAddress = dbAcc.EmailAddress; return(View(personRegistration)); } catch (Exception) { ViewBag.Message = "Sikertelen feldolgozás"; return(View(personRegistration)); } } else { return(RedirectToAction("Error", "Home")); } } catch (Exception) { return(RedirectToAction("Error", "Home")); } }
public object Get(CurrentAccount request) { var session = this.GetSession(); // Just in case someone was able to authenticate with a null session. if (!session.Id.HasValueTrimmed()) { throw new HttpError(HttpStatusCode.Forbidden, "NoSession"); } var account = _accountDao.FindById(new Guid(session.UserAuthId)); var creditCard = account.DefaultCreditCard.HasValue ? _creditCardDao.FindById(account.DefaultCreditCard.Value) : null; var creditCardResource = creditCard != null ? new CreditCardDetails { CreditCardId = creditCard.CreditCardId, AccountId = creditCard.AccountId, NameOnCard = creditCard.NameOnCard, Token = creditCard.Token, Last4Digits = creditCard.Last4Digits, CreditCardCompany = creditCard.CreditCardCompany, ExpirationMonth = creditCard.ExpirationMonth, ExpirationYear = creditCard.ExpirationYear, IsDeactivated = creditCard.IsDeactivated, Label = creditCard.Label, ZipCode = creditCard.ZipCode, StreetNumber = creditCard.StreetNumber, StreetName = creditCard.StreetName, Email = creditCard.Email, Phone = creditCard.Phone } : null; var currentAccount = new CurrentAccountResponse { Id = account.Id, Email = account.Email, Name = account.Name, IbsAccountid = account.IBSAccountId ?? 0, FacebookId = account.FacebookId, TwitterId = account.TwitterId, Settings = account.Settings, Language = account.Language, HasAdminAccess = account.HasAdminAccess, IsSuperAdmin = account.RoleNames.Contains(RoleName.SuperAdmin), DefaultCreditCard = creditCardResource, DefaultTipPercent = account.DefaultTipPercent, IsPayPalAccountLinked = account.IsPayPalAccountLinked }; currentAccount.Settings.ChargeTypeId = account.Settings.ChargeTypeId ?? _serverSettings.ServerData.DefaultBookingSettings.ChargeTypeId; currentAccount.Settings.VehicleTypeId = account.Settings.VehicleTypeId ?? _serverSettings.ServerData.DefaultBookingSettings.VehicleTypeId; currentAccount.Settings.ProviderId = account.Settings.ProviderId ?? _serverSettings.ServerData.DefaultBookingSettings.ProviderId; return(currentAccount); }
static void Main() { SavingsAccount saving = new SavingsAccount("0001", "S01A", 2000); Console.WriteLine(saving.ToString()); CurrentAccount current = new CurrentAccount("0002", "S02A", 2000); Console.WriteLine(current.ToString()); OverdraftAccount over1 = new OverdraftAccount("0003", "S03A", 2000); Console.WriteLine(over1.ToString()); OverdraftAccount over2 = new OverdraftAccount("0001", "S01A", -2000); Console.WriteLine(over2.ToString()); Console.WriteLine(); BankBranch branch = new BankBranch("TIAN TIAN"); branch.AddAccount(saving); branch.AddAccount(current); branch.AddAccount(over1); branch.AddAccount(over2); Console.WriteLine("Print all accounts: "); branch.PrintAccounts(); Console.WriteLine(); Console.WriteLine("Print total deposit:{0}", branch.TotalDeposits()); Console.WriteLine("Print total interestpaid:{0}", branch.TotalInterestPaid()); Console.WriteLine("Print total interestearned:{0}", branch.TotalInterestEarned()); Console.WriteLine(); Console.WriteLine("Print all customers: "); branch.PrintCustomers(); }
public async Task <ActionResult> Logout() { Domain.Resp resp = await CurrentAccount.Logout(); Response.Cookies.Delete(Defaults.ADMIN_AUTH_COOKIE_KEY); return(Pack(resp)); }
private void btnList_Click(object sender, EventArgs e) { var accounts = new List <Account>(); var c1 = new CurrentAccount(); c1.Titular = new Client("Fulano de tal", 26); accounts.Add(c1); var c2 = new SavingsAccount(); c2.Titular = new Client("Jecca", 46); accounts.Add(c2); accounts.Remove(c1); accounts.Add(c1); MessageBox.Show("Tem contas? R: " + accounts.Contains(c1)); foreach (Account acc in accounts) { MessageBox.Show("Titular: " + acc.Titular.Name); } MessageBox.Show("Total de contas: " + accounts.Count); }
private void btnAccountUpdater_Click(object sender, EventArgs e) { Account acc = new CurrentAccount(); acc.Deposit(2300.5); SavingsAccount sacc = new SavingsAccount(); sacc.Deposit(2051); CurrentAccount cacc = new CurrentAccount(); cacc.Deposit(5000); BankBalance bank = new BankBalance(); bank.SumAccount(acc); bank.SumAccount(sacc); bank.SumAccount(cacc); MessageBox.Show("Saldo do banco é: " + bank.Total); AccountUpdater updater = new AccountUpdater(0.05); updater.Run(acc); updater.Run(sacc); updater.Run(cacc); MessageBox.Show("Saldo ACC é: " + acc.Balance); MessageBox.Show("Saldo SACC é: " + sacc.Balance); MessageBox.Show("Saldo CACC é: " + cacc.Balance); }
private static void Main(string[] args) { CurrentAccount firstAccount = new CurrentAccount(); firstAccount.holder = "Isis Valverde"; Console.WriteLine(firstAccount.holder + ", your initial balance is R$ " + firstAccount.bankBalance); bool resultAfterWithdrawal = firstAccount.WithdrawalAmount(500); Console.WriteLine("Is it possible to withdraw R$ 500? " + resultAfterWithdrawal); Console.WriteLine("Your balance is R$ " + firstAccount.bankBalance); firstAccount.BankDeposit(500); Console.WriteLine("\nBalance after deposit of R$ 500 : " + firstAccount.bankBalance + "\n"); CurrentAccount secondAccount = new CurrentAccount(); secondAccount.holder = "Deborah Secco"; Console.WriteLine(firstAccount.holder + " account balance: R$ " + firstAccount.bankBalance); Console.WriteLine(secondAccount.holder + " account balance: R$ " + secondAccount.bankBalance); bool transferResult = firstAccount.BankTransfer(200, secondAccount); Console.WriteLine("\nTransferring R$ 200 from firstAccount to secondAccount...\n"); Console.WriteLine(firstAccount.holder + " account balance: R$ " + firstAccount.bankBalance); Console.WriteLine(secondAccount.holder + " account balance: R$ " + secondAccount.bankBalance); Console.WriteLine("Transfer result: " + transferResult); Console.ReadLine(); }
public ActionResult CompanyBankAccountOpening(int?Id) { try { var inDB = db.CurrentAccount.Where(hasValue => hasValue.PersonId == null && hasValue.CompanyId == null).FirstOrDefault(usr => usr.Id == Id).Equals(1); if (inDB == false) { CompanyRegistrationViewModel companyRegistration = new CompanyRegistrationViewModel(); try { CurrentAccount dbAcc = db.CurrentAccount.Where(model => model.Id == Id).FirstOrDefault(); companyRegistration.CompanyCommonData.AccountNumber = dbAcc.AccountNumber; companyRegistration.CompanyCommonData.EmailAddress = dbAcc.EmailAddress; return(View(companyRegistration)); } catch (Exception) { return(RedirectToAction("Error", "Home")); } } else { return(RedirectToAction("Error", "Home")); } } catch (Exception) { return(RedirectToAction("Error", "Home")); } }
private void AuthenticateButton_OnClick(object sender, RoutedEventArgs e) { CurrentAccount = AccountProxy.ChangeAccount(this.AccountCodeTextBox.Text); this.AccountPointsLabel.Content = $"You currently have {CurrentAccount.GetPointsAmount()} points"; this.PayFinalizeButton.IsEnabled = true; this.PointsFinalizeButton.IsEnabled = CurrentAccount.IsEnough(Convert.ToInt32(OrderPrice)); }
public void TestMakeDeposit() { CurrentAccount c = new CurrentAccount("Ac12345", 100); c.MakeDeposit(100); Assert.AreEqual(c.Balance, 100); }
public SetAccountRate(IAccountTypeRepository accountTypeRepository, IMapper mapper) { _accountTypeRepository = accountTypeRepository; _mapper = mapper; _savingAccount = new SavingAccount(); _currentAccount = new CurrentAccount(); }
public void TestMakeWithdrawal() { CurrentAccount c = new CurrentAccount("Ac12345", 100); c.MakeWithdrawal(50); Assert.AreEqual(c.Balance, -50); }
private void OnLoginRes(object obj) { JObject data = JObject.Parse(obj.ToString()); bool status = (bool)data["status"]; if (status) { GV.IsLoggedIn = true; //Move to main dashboard CurrentAccount CA = new CurrentAccount( data["accDetail"]["ID"].ToString(), data["accDetail"]["FirstName"].ToString(), data["accDetail"]["LastName"].ToString(), totalMoney: decimal.Parse(data["accDetail"]["TotalMoney"].ToString()) ); CA.CalcMovments(data); GV.CA = CA; TrasitionToDashBoard(); } else { string err = data["err"].ToString(); MessageBox.Show(err, "Login Error", MessageBoxButton.OK, MessageBoxImage.Error); GV.IsLoggedIn = false; LoginBtnActiveState = true; } }
public EditAccountForm(int accountId) { CurrentAccount acc = new CurrentAccount(); InitializeComponent(); txtAccId.Text = accountId.ToString();// EditExistingAccount exa = new EditExistingAccount(); acc = exa.RetrieveAccount(accountId); txtFName.Text = acc.FirstName; txtSurname.Text = acc.Surname; txtEmail.Text = acc.Email; txtPhone.Text = acc.Phone; txtAddress1.Text = acc.AddressLine1; txtAddress2.Text = acc.AddressLine2; txtCity.Text = acc.City; cbxCounty.Text = acc.Country; cbxAccountType.Text = acc.AccountType; txtAccountNumber.Text = acc.AccountNumber.ToString(); txtSortCode.Text = "101010"; txtOpeningBalance.Text = acc.InitialBalance.ToString(); txtOverdraftLimit.Text = acc.OverdraftLimit.ToString(); //dis-enable the overdraft textbox for a savings account if (cbxAccountType.Text == "Savings") { txtOverdraftLimit.Enabled = false; } else { txtOverdraftLimit.Enabled = true; } }
// GET: AddAccount public ActionResult Index(string id) { var account = new CurrentAccount { Balance = 2000, SortCode = "123456", AccountNumber = "12345678" }; var customer = new ApplicationUser { FirstName = "John", LastName = "Smith", DateOfBirth = new DateTime(2000, 1, 18), MyAccounts = new List <BankAccountBase>(), Email = "*****@*****.**", Address = "afadasd" }; using (var _context = new ApplicationDbContext()) { var user = (ApplicationUser)_context.Users.Where(u => u.Id == id); user.MyAccounts.Add(account); return(View(user)); } //customer.MyAccounts.Add(account); }
public void OpenDepositWithDrawCloseAccountTest(string userName, double minimumBalance) { //Arrange CurrentAccount currentAccount = new CurrentAccount(LedgerRepo, AccountRepo); if ((!string.IsNullOrWhiteSpace(userName)) && (minimumBalance > 1000)) { //Act var accountNumber = currentAccount.OpenAccount(userName, minimumBalance); var accountNumberLength = accountNumber.ToString().Length; //Assert Assert.Equal(12, accountNumberLength); currentAccount.DepositAmount(7000); var withdrawStatus = currentAccount.WithdrawlAmount(2001); Assert.True(withdrawStatus); Assert.True(currentAccount.CloseAccount()); } else if (string.IsNullOrWhiteSpace(userName)) { Assert.Throws <BankException>(() => currentAccount.OpenAccount("", minimumBalance) ); } }
private void OnQueryPosition() { if (CurrentAccount.VerifyStatus()) { EventAggregator.GetEvent <QueryPositionEvent>().Publish(CurrentAccount); } }
private void btnOpslaan_Click(object sender, EventArgs e) { if (tbName.Text != "" && tbUserName.Text != "" && cbFunction.Text != "" && (tbNewPassword.Text != "" || tbRepeatPassword.Text != "")) //change account and password { if (tbNewPassword.Text == tbRepeatPassword.Text) //If passwords are the same { Account Account = new Account(CurrentAccount.ID, tbName.Text, tbUserName.Text, tbNewPassword.Text, (Function)Enum.Parse(typeof(Function), cbFunction.Text)); bool Check = Account.EditAccount(Account); CurrentAccount.UpdateAccount(Account); CheckUserName(Check); } else { MessageBox.Show("Wachtwoorden komen niet overeen"); } } else if (tbName.Text != "" && tbUserName.Text != "" && cbFunction.Text != "") //Don't change password { Account Account = new Account(CurrentAccount.ID, tbName.Text, tbUserName.Text, tbOldPassword.Text, (Function)Enum.Parse(typeof(Function), cbFunction.Text)); bool Check = Account.EditAccount(Account); CurrentAccount.UpdateAccount(Account); CheckUserName(Check); } else { MessageBox.Show("Niet alle gegevens zijn correct ingevuld"); } }
public void TestInvalidAccNumberOverdraftWithdrawal() { BankPolicy.minimumcurrentBalance = 1000; CurrentAccount account = new CurrentAccount("Customer", "000000", 1200.00); double actual = account.overdraftWithdraw("000000", 20000.00); }
private Account CalculateInterest(Account account) { _account = account; _accountTypeName = account.AccountType.Type; _interestAddedCurrentAccount = new CurrentAccount(); _interestAddedSavingAccount = new SavingAccount(); switch (_accountTypeName) { case "Current Account": _interestAddedCurrentAccount = new CurrentAccount(); _interestAddedCurrentAccount.CurrentBalance = account.CurrentBalance; _interestAddedCurrentAccount.CalculateRate(); _account.CurrentBalance = _interestAddedCurrentAccount.CurrentBalance; break; case "Saving Account": _interestAddedSavingAccount = new SavingAccount(); _interestAddedSavingAccount.CurrentBalance = account.CurrentBalance; _interestAddedSavingAccount.CalculateRate(); _account.CurrentBalance = _interestAddedSavingAccount.CurrentBalance; break; default: Console.WriteLine("Default case"); break; } return(_account); }
private void PersonalDetailsContinueButton_Click(object sender, EventArgs e) { DateTime.TryParse(dateOfBirth.Text, out DateTime dob); Account acc = new CurrentAccount(100m, 1234567890L); Address address = new Address { Line1 = AddressLine1TextBox.Text, Line2 = AddressLine2TextBox.Text, City = CityTextBox.Text, County = CountyTextBox.Text, Postcode = PostcodeTextbox.Text }; AccountHolder ah = new AccountHolder { MyAccount = acc, LastName = LastNameTextBox.Text, Prefix = TitleTextBox.Text, FirstName = FirstNameTextBox.Text, MiddleName = MiddleNameTextBox.Text, DateOfBirth = dob, MyAddress = address, AccountType = AccountTypeComboBox.Text }; bool isSuccess = NewAccountController.Process(ah); }
static void Main(string[] args) { BankAccount a1 = new BankAccount("John", 5000); BankAccount a2 = new BankAccount("Tom", 9600, AccountType.Current); //a2.Depositor = "Max"; Console.WriteLine("Enter Your name"); string name = Console.ReadLine(); /* * Console.WriteLine("Enter Your Account Number"); * int accountNumber = int.Parse(Console.ReadLine());*/ Console.WriteLine("Enter Your Account Type (Savings/Current)"); AccountType accountType = (AccountType)Enum.Parse(typeof(AccountType), (Console.ReadLine())); if (accountType == AccountType.Savings) { //BankAccount a3 = new BankAccount(name, 0, accountType, accountNumber); SavingAccount a3 = new SavingAccount(name, 0); Menu(a3); } else { CurrentAccount a3 = new CurrentAccount(name, 0); Menu(a3); } }
static void Main() { IBankAccount venusAccount = new SaverAccount(); ITransferBankAccount jupiterAccount = new CurrentAccount(); venusAccount.PayIn(200); jupiterAccount.PayIn(500); jupiterAccount.TransferTo(venusAccount, 100); Console.WriteLine(venusAccount.ToString()); Console.WriteLine(jupiterAccount.ToString()); }
static void Main(string[] args) { IBankAccount venusAccount = new SaverAccount(); ITransferBankAccount jupiterAccount = new CurrentAccount(); venusAccount.PayIn(200); Console.WriteLine(venusAccount.ToString()); jupiterAccount.PayIn(500); jupiterAccount.PayIn(400); jupiterAccount.Withdraw(500); jupiterAccount.Withdraw(100); Console.WriteLine(jupiterAccount.ToString()); bool isTrans = jupiterAccount.TransferTo(venusAccount, 300); if (isTrans) { Console.WriteLine("转账后:" + jupiterAccount.ToString()); Console.WriteLine("转账后: " + venusAccount.ToString()); } else { Console.WriteLine("转账失败"); } Console.Read(); }