static void Main() { IndividualCustomer pesho = new IndividualCustomer("Petar", "Petrov", "+359894011468", "Sofia, bul.Tcarigradsko shose 15"); IndividualCustomer mimi = new IndividualCustomer("Maria", "Nikolova", "+359894011468", "Sofia, bul.Vitoshka 35"); CompanyCustomer softUni = new CompanyCustomer("Software University Ltd.", "+359894011468", "Sofia, bul.NqkoiSi 9"); CompanyCustomer hardUni = new CompanyCustomer("Hardware University Ltd.", "+359894011468", "Sofia, bul.EdiKoiSi 6"); Deposit d1 = new Deposit(pesho, 1000, 0.1m); Deposit d2 = new Deposit(softUni, 50000, 0.15m); Loan l1 = new Loan(mimi, 5500, 0.2m); Loan l2 = new Loan(hardUni, 90000, 0.18m); Mortgage m1 = new Mortgage(pesho, 60000, 0.12m); Mortgage m2 = new Mortgage(hardUni, 160000, 0.1m); Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("Deposits and withdraws:"); Console.ForegroundColor = ConsoleColor.Black; Console.Write("Old balance " + d1.Balance + ", new balance: "); d1.DepositMoney(500); Console.WriteLine(d1.Balance); Console.Write("Old balance " + d2.Balance + ", new balance: "); d2.WithdrawMoney(12500.50m); Console.WriteLine(d2.Balance); Console.Write("Old balance " + l1.Balance + ", new balance: "); l1.DepositMoney(500); Console.WriteLine(l1.Balance); Console.Write("Old balance " + m1.Balance + ", new balance: "); m1.DepositMoney(10000.90m); Console.WriteLine(m1.Balance); Console.WriteLine(); IList<Account> accounts = new List<Account> { d1, d2, l1, l2, m1, m2 }; Bank bank = new Bank(accounts); Console.WriteLine("The bank:"); Console.WriteLine(bank); // I have changed the formula for calculating the interest, because // the given formula returns interest plus amount which is not correct Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("Calculated interests:"); Console.ForegroundColor = ConsoleColor.Black; Console.WriteLine("Interest = {0:F2} BGN", d1.CalculateInteres(6)); Console.WriteLine("Interest = {0:F2} BGN", l1.CalculateInteres(3)); Console.WriteLine("Interest = {0:F2} BGN", l2.CalculateInteres(6)); Console.WriteLine("Interest = {0:F2} BGN", d2.CalculateInteres(6)); Console.WriteLine("Interest = {0:F2} BGN", m1.CalculateInteres(6)); Console.WriteLine("Interest = {0:F2} BGN", m1.CalculateInteres(13)); Console.WriteLine("Interest = {0:F2} BGN", m2.CalculateInteres(6)); }
public Customer ChangeName(int parentId, ODataActionParameters odataParams) { IndividualCustomer ic = new IndividualCustomer(); ic.Id = 1; ic.Name = "kiran"; ic.SSN = "111111111"; return ic; }
static void Main() { Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US"); Customer depositAccountCustomer = new IndividualCustomer( "123456789AA", "Pesho", "Peshov", "Sofia, Bulgaria, Tzarigradsko shose 2", "555-123-123"); DepositAccount depositAccount = new DepositAccount( depositAccountCustomer, 2000, 0.1234M, 36); Customer loanAccountCustomer = new CorporateCustomer( "123456789AB", "Oracle Corporation", "Sofia, Bulgaria, Tzarigradsko shose 20", "555-123-321"); Account loanAccount = new LoanAccount( loanAccountCustomer, 9000000000, 0.1234M, 24); Customer mortgageLoanAccountCustomer = new IndividualCustomer( "223456789AA", "Ginni", "Rometty", "Sofia, Bulgaria, Tzarigradsko shose 22", "555-321-321"); Account mortgageLoanAccount = new MortgageLoanAccount( mortgageLoanAccountCustomer, 990000, 0.1234M, 12); decimal depositInterest = depositAccount.CalculateInterest(3); Console.WriteLine("Deposit account interest: {0:C2}", depositInterest); depositAccount.Deposit(459.76M); depositAccount.Withdraw(400.76M); Console.WriteLine("Deposit account balance: {0:C2}", depositAccount.Balance); decimal loanInterest = loanAccount.CalculateInterest(10); Console.WriteLine("Loan account interest: {0:C2}", loanInterest); decimal mortgageLoanInterest = mortgageLoanAccount.CalculateInterest(10); Console.WriteLine("Mortgage loan account interest: {0:C2}", mortgageLoanInterest); }
static void Main() { Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US"); Customer depositAccountCustomer = new IndividualCustomer( "2343PJ34752", "William", "Harris", "1 Microsoft Way, Redmond, WA", "1-888-553-6562"); DepositAccount depositAccount = new DepositAccount( depositAccountCustomer, 2500, 1.0825M, 12); Customer loanAccountCustomer = new CorporateCustomer( "89BPQ123YJ0", "Oracle Corporation", "500 Oracle Parkway, Redwood Shores, Redwood City, California, United States", "1-981-717-9366"); Account loanAccount = new LoanAccount( loanAccountCustomer, 1000000000, 1.0931M, 24); Customer mortgageLoanAccountCustomer = new IndividualCustomer( "97A20LX3YJU", "Ginni", "Rometty", "Armonk, New York, U.S.", "1-129-342-3817"); Account mortgageLoanAccount = new MortgageLoanAccount( mortgageLoanAccountCustomer, 300000, 1.0875M, 36); decimal depositInterest = depositAccount.CalculateInterest(3); Console.WriteLine("Deposit account interest: {0:C2}", depositInterest); depositAccount.Deposit(459.76M); depositAccount.Withdraw(400.76M); Console.WriteLine("Deposit account balance: {0:C2}", depositAccount.Balance); decimal loanInterest = loanAccount.CalculateInterest(10); Console.WriteLine("Loan account interest: {0:C2}", loanInterest); decimal mortgageLoanInterest = mortgageLoanAccount.CalculateInterest(10); Console.WriteLine("Mortgage loan account interest: {0:C2}", mortgageLoanInterest); }
static void Main() { var customer = new IndividualCustomer("Pesho", "Sofia"); var bankAccount = new DepositAccount(customer, 30.4); bankAccount.Deposit(2000M); Console.WriteLine("Current balance: {0}",bankAccount.Balance); Console.WriteLine("Interest amount: {0}", bankAccount.GetInterestAmount(23)); bankAccount.Withdraw(160.50M); Console.WriteLine("Current balance: {0}",bankAccount.Balance); }
static void Main() { //Making customers - individual and company CompanyCustomer ood = new CompanyCustomer("OOD"); IndividualCustomer samuel = new IndividualCustomer("Samuel L. Jackson"); //Testing some stuff DepositAccount samuelDepositAccount = new DepositAccount(samuel , 10000m, 100m); DepositAccount oodDepositAccount = new DepositAccount(ood, 10000m, 100m); Console.WriteLine("{1} has {0} money.", samuelDepositAccount.Balance, samuelDepositAccount.Customer.Name); samuelDepositAccount.WithDrawMoney(500m); Console.WriteLine("After we with draw some money he has {0} money." , samuelDepositAccount.Balance); samuelDepositAccount.AddDeposit(200m); Console.WriteLine("After we deposit some money he has " + samuelDepositAccount.Balance); Console.WriteLine(); Console.WriteLine(); //Testing the deposit account Console.WriteLine("Testing the deposit account:"); Console.WriteLine("----------------------------"); Console.WriteLine("The {0} of {2} who is a {1} has interest amount for next 6 mounths: {3} " , samuelDepositAccount.GetType(), samuelDepositAccount.Customer.GetType(), samuelDepositAccount.Customer.Name, samuelDepositAccount.InterestAmountForPeriod(6)); Console.WriteLine("The {0} of {2} who is a {1} has interest amount for next 6 mounths: {3} " , oodDepositAccount.GetType(), oodDepositAccount.Customer.GetType(), oodDepositAccount.Customer.Name, oodDepositAccount.InterestAmountForPeriod(6)); Console.WriteLine(); Console.WriteLine(); //Testing the loan account Console.WriteLine("Testing the loan account:"); Console.WriteLine("----------------------------"); LoanAccount samuelLoanAccount = new LoanAccount(samuel, 10000m, 100m); Console.WriteLine("The {0} of {2} who is a {1} has interest amount for next 6 mounths: {3} " , samuelLoanAccount.GetType(), samuelLoanAccount.Customer.GetType(), samuelLoanAccount.Customer.Name, samuelLoanAccount.InterestAmountForPeriod(6)); LoanAccount oodLoanAccount = new LoanAccount(ood, 10000m, 100m); Console.WriteLine("The {0} of {2} who is a {1} has interest amount for next 6 mounths: {3} " , oodLoanAccount.GetType(), oodLoanAccount.Customer.GetType(), oodLoanAccount.Customer.Name, oodLoanAccount.InterestAmountForPeriod(6)); Console.WriteLine(); Console.WriteLine(); //Testing the mortage account Console.WriteLine("Testing the mortage account:"); Console.WriteLine("----------------------------"); MortageAccount samuelMortageAccount = new MortageAccount(samuel, 10000m, 100m); Console.WriteLine("The {0} of {2} who is a {1} has interest amount for next 24 mounths: {3} " , samuelMortageAccount.GetType(), samuelMortageAccount.Customer.GetType(), samuelMortageAccount.Customer.Name, samuelMortageAccount.InterestAmountForPeriod(24)); MortageAccount oodMortageAccount = new MortageAccount(ood, 10000m, 100m); Console.WriteLine("The {0} of {2} who is a {1} has interest amount for next 24 mounths: {3} " , oodMortageAccount.GetType(), oodMortageAccount.Customer.GetType(), oodMortageAccount.Customer.Name, oodMortageAccount.InterestAmountForPeriod(24)); }
//Insert public List <IndividualCustomer> POST(IndividualCustomer customer) { CustomerDataContext customerDataAccess = new CustomerDataContext(); if (ModelState.IsValid) { //Save Customer customerDataAccess.Customers.Add(customer); customerDataAccess.SaveChanges(); } List <IndividualCustomer> customers = customerDataAccess.Customers.ToList <IndividualCustomer>(); return(customers); }
// GET: IndividualCustomers/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } IndividualCustomer individualCustomer = _individualCustomerRepository.Get().Where(x => x.IndividualCustomerId == id).Fetch().FirstOrDefault(); if (individualCustomer == null) { return(HttpNotFound()); } return(View(individualCustomer)); }
// GET: IndividualCustomers/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } IndividualCustomer individualCustomer = _individualCustomerRepository.Get().Where(x => x.IndividualCustomerId == id).Fetch().FirstOrDefault(); if (individualCustomer == null) { return(HttpNotFound()); } ViewBag.SalesAgentId = new SelectList(_salesAgentRepository.Get().Fetch(), "SalesAgentId", "Name", individualCustomer.SalesAgentId); return(View(individualCustomer)); }
//Update public List <IndividualCustomer> Delete(IndividualCustomer customer) { CustomerDataContext customerDataAccess = new CustomerDataContext(); //Delete Customer IndividualCustomer customerDelete = (from item in customerDataAccess.Customers where item.CustomerCode == customer.CustomerCode select item).FirstOrDefault(); customerDataAccess.Customers.Remove(customerDelete); customerDataAccess.SaveChanges(); //Return Customer List <IndividualCustomer> customers = customerDataAccess.Customers.ToList <IndividualCustomer>(); return(customers); }
public void TestAccountConstructor4_ThrowsException() { Customer accountCustomer = new IndividualCustomer( "2343PJ34752", "William", "Harris", "1 Microsoft Way, Redmond, WA", "1-888-553-6562"); Account account = new DepositAccount( accountCustomer, 2500, -1.0825M, 12); }
public ActionResult Create() { var titles = GetTitles(); var customer = new IndividualCustomer { GetCards = GetCards(), GetState = GetState(), AddressIding = AddressIding(), Emailnotifications = Emailnotifictions(), Phonetype = Phonetype(), TitleList = GetSelectListItems(titles) }; return(View(customer)); }
static void Main() { IndividualCustomer cst = new IndividualCustomer("Ivo", "Pavlev", "Andonov", "083472221"); DepositAccount depositAcc = new DepositAccount(cst, 1000, 0.5m); Console.WriteLine(depositAcc); // depositAcc.WithDraw(20); Console.WriteLine("New balance:{0}", depositAcc.Balance); // depositAcc.Deposit(100000); Console.WriteLine("New balance:{0}", depositAcc.Balance); Console.WriteLine("{0:0.0}", depositAcc.CalculateInterestAmount(12)); //------------------------------------------------------------------------------ Console.WriteLine(); IndividualCustomer cst1 = new IndividualCustomer("Ivo", "Pavlev", "Andonov", "083472221"); LoanAccount loanAcc = new LoanAccount(cst1, 1000, 1m); Console.WriteLine(loanAcc); loanAcc.Deposit(50); // depositAcc.WithDraw(20); // depositAcc.Deposit(100000); Console.WriteLine("New balance:{0}", loanAcc.Balance); Console.WriteLine("{0:0.0}", loanAcc.CalculateInterestAmount(5)); //------------------------------------------------------------------------------ Console.WriteLine(); IndividualCustomer cst2 = new IndividualCustomer("Ivo", "Pavlev", "Andonov", "083472221"); MortgageAccount mortageAcc = new MortgageAccount(cst2, 1000, 1m); Console.WriteLine(mortageAcc); mortageAcc.Deposit(50); // depositAcc.WithDraw(20); // depositAcc.Deposit(100000); Console.WriteLine("New balance:{0}", mortageAcc.Balance); Console.WriteLine("{0:0.0}", mortageAcc.CalculateInterestAmount(7)); //------------------------------------------------------------------------------ Console.WriteLine(); CompanyCustomer cst3 = new CompanyCustomer("Masson", "083472221"); MortgageAccount mortageAcc1 = new MortgageAccount(cst3, 10000, 1m); Console.WriteLine(mortageAcc1); mortageAcc1.Deposit(50); // depositAcc.WithDraw(20); // depositAcc.Deposit(100000); Console.WriteLine("New balance:{0}", mortageAcc1.Balance); Console.WriteLine("{0:0.0}", mortageAcc1.CalculateInterestAmount(24)); }
static void Main() { IndividualCustomer kuncho = new IndividualCustomer("Kuncho"); CompanyCustomer mtel = new CompanyCustomer("Mtel"); LoanAccount loanAcc = new LoanAccount(kuncho, 250, 25); DepositAccount depositAcc = new DepositAccount(mtel, 10000, 20); loanAcc.DepositAmmount(100); Console.WriteLine(loanAcc.Balance); depositAcc.WithdrawAmount(5000); Console.WriteLine(depositAcc.Balance); Console.WriteLine(depositAcc.CalculateInterestAmount(12)); }
static void Main() { IndividualCustomer pesho = new IndividualCustomer("Pesho"); CompanyCustomer tsarvulInvestment = new CompanyCustomer("Tsarvul Investment"); //SixMonthDeposit depositPesho = new SixMonthDeposit(pesho, 1500m, 3.2m, DepositType.SixMonth, Accounts.AccountType.Personal); //decimal interestDeposit = depositPesho.CalculateInterest(5); //Console.WriteLine(interestDeposit); //SixMonthLoan loanPesho = new SixMonthLoan(pesho, 1500m, 3.2m, LoanType.SixMonth, AccountType.Personal); //decimal interestLoan = loanPesho.CalculateInterest(4); //Console.WriteLine(interestLoan); ThirtyYearMortgage mortgage = new ThirtyYearMortgage (tsarvulInvestment, 10000m, 3.2m, AccountType.Company, MortgageType.ThirtyYear); decimal interest = mortgage.CalculateInterest(12); Console.WriteLine(interest); }
private static void CreateNewAccount() { Console.Clear(); string customerType; IndividualCustomer inCustomer; CompanyCustomer compCustomer; do { Console.Write("Enter Customer Type(Individual/Company): "); customerType = Console.ReadLine(); }while (!String.Equals(customerType, "Individual") && !String.Equals(customerType, "Company")); if (String.Equals(customerType, "Individual")) { Console.Write("Enter First Name: "); var firstName = Console.ReadLine(); Console.Write("Enter Last Name: "); var lastName = Console.ReadLine(); int customerId = (_customers.OrderByDescending(c => c.CustomerId).FirstOrDefault().CustomerId) + 1; inCustomer = new IndividualCustomer { CustomerId = customerId, FirstName = firstName, LastName = lastName }; _customers.Add(inCustomer); CreateAccount(inCustomer); } else { Console.Write("Enter Company Name"); var companyName = Console.ReadLine(); int customerId = (_customers.OrderByDescending(c => c.CustomerId).FirstOrDefault().CustomerId) + 1; compCustomer = new CompanyCustomer { CustomerId = customerId, CompanyName = companyName }; _customers.Add(compCustomer); CreateAccount(compCustomer); } ShowListOfAccounts(); }
public void TestAccountConstructor2() { Customer accountCustomer = new IndividualCustomer( "2343PJ34752", "William", "Harris", "1 Microsoft Way, Redmond, WA", "1-888-553-6562"); Account account = new DepositAccount( accountCustomer, 2500, 1.0825M, 12); Assert.AreEqual(1.0825M, account.MonthlyInterestRate); }
private static void AddIndividualCustomer(IndividualCustomerManager individualCustomerManager) { var customer = new IndividualCustomer { IdentityNo = "12345678910", FirstName = "Ali", LastName = "Yaman", DOB = Convert.ToDateTime("10/10/1990"), PhoneNumber = "05556667788", Address = "İzmir", Email = "*****@*****.**", PasswordHash = Encoding.ASCII.GetBytes("12345"), JoinDate = DateTime.Now }; individualCustomerManager.Add(customer); }
//Update public List <IndividualCustomer> PUT(IndividualCustomer customer) { CustomerDataContext customerDataAccess = new CustomerDataContext(); //Update Customer IndividualCustomer customerUpdate = (from item in customerDataAccess.Customers where item.CustomerCode == customer.CustomerCode select item).FirstOrDefault(); customerUpdate.CustomerName = customer.CustomerName; customerUpdate.CustomerDob = customer.CustomerDob; customerUpdate.CustomerAmount = customer.CustomerAmount; //Return Customer List <IndividualCustomer> customers = customerDataAccess.Customers.ToList <IndividualCustomer>(); return(customers); }
public static void Main() { Customer kircho = new IndividualCustomer("Kircho Kirev"); Customer bulPc = new CompanyCustomer("BulPC"); List <Account> accounts = new List <Account> { new DepositAccount(kircho, 22500m, 7.2m), new LoanAccount(bulPc, 50000m, 12.3m), new MortgageAccount(kircho, 100250m, 9.1m) }; foreach (Account account in accounts) { Console.WriteLine(account.GetType() + " Interest:{0:F2}", account.CalculateInterest(15)); } }
public static void Main() { CompanyCustomer company = new CompanyCustomer("Company"); IndividualCustomer pesho = new IndividualCustomer("Pesho"); IndividualCustomer ivan = new IndividualCustomer("Ivan"); IAccount peshoLoan = new Loan(pesho, 2500, 6.5m); IAccount companyMortgage = new Mortgage(company, 15000, 8.8m); IAccount ivanDeposit = new Deposit(ivan, 8000, 3.5m); List<IAccount> myAccounts = new List<IAccount>{peshoLoan, companyMortgage, ivanDeposit}; Bank bigBank = new Bank(myAccounts); Console.WriteLine(); bigBank.ListAllAccounts(); Console.WriteLine(); bigBank.InterestForAll(12); Console.WriteLine("\nPesho's interest for 30 months: {0}", peshoLoan.CalculateInterest(30)); Console.WriteLine(); }
public IndividualCustomer GET(String CustomerCode) { var allUrlKeyValues = ControllerContext.Request.GetQueryNameValuePairs(); string CustomerCode1 = allUrlKeyValues. SingleOrDefault(x => x.Key == "CustomerCode").Value; string CustomerName1 = allUrlKeyValues. SingleOrDefault(x => x.Key == "CustomerName").Value; CustomerDataContext customerDataAccess = new CustomerDataContext(); IndividualCustomer customers = null; customers = (from item in customerDataAccess.Customers where item.CustomerCode.ToUpper() == CustomerCode.ToUpper() select item).FirstOrDefault(); return(customers); }
public void TestWithdrawMethod() { Customer accountCustomer = new IndividualCustomer( "2343PJ34752", "William", "Harris", "1 Microsoft Way, Redmond, WA", "1-888-553-6562"); DepositAccount account = new DepositAccount( accountCustomer, 2500, 1.0825M, 12); account.Withdraw(400M); Assert.AreEqual(2100M, account.Balance); }
static void Main(string[] args) { Customer indiv1 = new IndividualCustomer("Ivan Todorov"); Customer indiv2 = new IndividualCustomer("Georgi Georgiev"); Customer comp = new CompanyCustomer("Toplivo AD"); Account[] someAccounts = new Account[4] { new DepositAccount(indiv1,1020,0.4m), new LoanAccount(indiv2,300,3), new MortgageAccount(indiv2,20000,2), new DepositAccount(comp,4000,4) }; foreach (var item in someAccounts) { Console.WriteLine(item.CalculateInterest(5)); } }
static void Main() { Bank bank = new Bank("OOP"); // fill in some random records for (int i = 0; i < numberOfCustomers; i++) { Customer client; if (vladoRandoma.Next() % 2 == 0) { client = new Company(companyNames[vladoRandoma.Next(0, companyNames.Length)]); } else { client = new IndividualCustomer(fnames[i] + " " + lnames[i]); } switch (vladoRandoma.Next() % 3) { case 1: bank.AddAccount(new Loan(client, vladoRandoma.Next(100, 10000), vladoRandoma.Next(0, 36))); break; case 2: bank.AddAccount(new Mortgage(client, vladoRandoma.Next(100, 10000), vladoRandoma.Next(0, 36))); break; case 0: bank.AddAccount(new Deposit(client, vladoRandoma.Next(100, 10000), vladoRandoma.Next(0, 36))); break; default: break; } } bank.PrintAccounts(); foreach (var item in bank.Customers) { bank[item.Name].Deposit(500); } foreach (var item in bank.Customers) { bank[item.Name].Draw(1000); } }
public void TestDepositMethod() { Customer accountCustomer = new IndividualCustomer( "2343PJ34752", "William", "Harris", "1 Microsoft Way, Redmond, WA", "1-888-553-6562"); Account account = new DepositAccount( accountCustomer, 32500, 1.0825M, 12); account.Deposit(459M); Assert.AreEqual(32959M, account.Balance); }
static void Main() { // Creating some customers IndividualCustomer customer1 = new IndividualCustomer("Ivan", "Ivanov", 11223344); CompanyCustomer customer2 = new CompanyCustomer("Company 0101", 99887766); CompanyCustomer customer3 = new CompanyCustomer("Company 123", 22334455); // Creating different kinds of accounts DepositAccount account1 = new DepositAccount(customer1, 20000m, 10m); LoanAccount account2 = new LoanAccount(customer2, 5000m, 6.8m); DepositAccount account3 = new DepositAccount(customer3, 3400m, 16.4m); // Creating the bank with the accounts List <Account> accounts = new List <Account>() { account1, account2, account3 }; Bank bank = new Bank("G Bank", accounts); // Adding account to the bank IndividualCustomer customer4 = new IndividualCustomer("Georgi", "Georgiev", 66778800); MortgageAccount account4 = new MortgageAccount(customer4, 2000m, 4.1m); bank.AddAccount(account4); // Printing all the information about the bank and its clients on the console Console.WriteLine(bank); // Depositting and withdrawing money to account1 account1.DepositMoney(100m); account1.WithdrawMoney(2000m); Console.WriteLine("After depositting and withdrawing money from {0} {1}'s account the balance is: {2:C2}", customer1.Fname, customer1.Lname, account1.Balance); Console.WriteLine(); // Calculating the interest amount for all the accounts in the bank Console.WriteLine("Deposit account interest amount after 5 months: {0:C2}", account1.CalculateInterestAmount(5)); account3.WithdrawMoney(2600m); Console.WriteLine("Deposit account interest amount after 2 months: {0:C2}", account3.CalculateInterestAmount(2)); Console.WriteLine("Loan account interest amount after 10 months: {0:C2}", account2.CalculateInterestAmount(10)); Console.WriteLine("Mortgage account interest amount after 1 year: {0:C2}", account4.CalculateInterestAmount(12)); }
public ActionResult Edit(int BusinessEntityID) { IndividualCustomer person = new IndividualCustomer(); CustomerPageViewModel pageViewModel = new CustomerPageViewModel(this); IEnumerable <string> titles = GetTitles(); IEnumerable <string> genders = GetGenders(); person.TitleList = GetSelectListItems(titles); person.GenderList = GetSelectListItems(genders); person.GetCards = GetCards(); person.GetState = GetState(); person.AddressIding = AddressIding(); person.Emailnotifications = Emailnotifictions(); person.Phonetype = Phonetype(); person = pageViewModel.SingleCustomer(BusinessEntityID); if (person == null) { return(HttpNotFound()); } return(View(person)); }
private static void InitializeAccountsAndCustomers() { var cust1 = new IndividualCustomer { CustomerId = 1, FirstName = "Tyrion", LastName = "Lannister" }; _customers.Add(cust1); var cust2 = new IndividualCustomer { CustomerId = 2, FirstName = "Jon", LastName = "Snow" }; _customers.Add(cust2); var cust3 = new CompanyCustomer { CustomerId = 3, CompanyName = "Faceless Men" }; _customers.Add(cust3); var acc1 = new DepositAccount(cust1, 20000, "ABC00001"); _accounts.Add(acc1); var acc2 = new DepositAccount(cust2, 25000, "ABC00002"); _accounts.Add(acc2); var acc3 = new MortgageAccount(cust2, 35000, "ABC00003"); _accounts.Add(acc3); var acc4 = new LoanAccount(cust3, 500000, "ABC00004"); _accounts.Add(acc4); }
static void Main() { // Customers Customer[] customers = new Customer[4]; customers[0] = new IndividualCustomer("Iliqn Petrov", 59784, "0894719648"); customers[1] = new CompanieCustomer("Kiril Iliev", 81746, "0881446720"); customers[2] = new IndividualCustomer("Nikolai Grancharov", 91002, "0874100359"); customers[3] = new CompanieCustomer("Kiril Slavqnov", 00147, "0886979231"); // Accounts DepositAccount firstDeposit = new DepositAccount(customers[0], 3000, 0.10m, 12); BankAccount[] accounts = new BankAccount[5]; accounts[0] = firstDeposit; accounts[1] = new LoanAccount(customers[1], 5000, 0.08m, 6); accounts[2] = new LoanAccount(customers[2], 5000, 0.08m, 6); accounts[3] = new MortgageAccount(customers[2], 22900, 0.11m, 48); accounts[4] = new MortgageAccount(customers[3], 22900, 0.11m, 48); // Print 1 Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine("First Print ..."); Console.ResetColor(); foreach (var item in accounts) { Console.WriteLine(item); Console.WriteLine(); } // Withdraw & Deposit firstDeposit.Withdraw(250); firstDeposit.Deposit(600); // Print 2 Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine("Second Print ..."); Console.ResetColor(); Console.WriteLine(accounts[0]); Console.ReadLine(); }
public ActionResult Edit(IndividualCustomer person) { CustomerPageViewModel pageViewModel = new CustomerPageViewModel(this); IEnumerable <string> titles = GetTitles(); IEnumerable <string> genders = GetGenders(); person.TitleList = GetSelectListItems(titles); person.GenderList = GetSelectListItems(genders); person.GetCards = GetCards(); person.GetState = GetState(); person.AddressIding = AddressIding(); person.Emailnotifications = Emailnotifictions(); person.Phonetype = Phonetype(); try { if (ModelState.IsValid) { pageViewModel.UpdateCustomer(person); unit.Save(); return(RedirectToAction("Index")); } else { ModelState.AddModelError("", "Unable to save to db"); return(View(person)); } } catch (DbEntityValidationException e) { var r = e.EntityValidationErrors .SelectMany(x => x.ValidationErrors) .Select(x => x.ErrorMessage); var fullErrorText = string.Join(";", r); var exeptionText = string.Concat(e.Message, "Your Errors are: ", fullErrorText); ModelState.AddModelError("", exeptionText); } return(View(person)); }
public static void Main() { // These examples and most of the solutions for the classes are taken from the forum // I actually "did read" all of the code and changed a couple of things ICustomer pesho = new IndividualCustomer("Petar Petrov"); ICustomer agroCompany = new CompanyCustomer("Agro Company Ltd."); IAccount mortgageAccInd = new MortgageAccount(pesho, 1024m, 5.3m); IAccount mortgageAccComp = new MortgageAccount(agroCompany, 1024m, 5.3m); IAccount loanAccInd = new LoanAccount(pesho, 1024m, 5.3m); IAccount loanAccComp = new LoanAccount(agroCompany, 1024m, 5.3m); IAccount depositAccIndBig = new DepositAccount(pesho, 1024m, 5.3m); IAccount depositAccIndSmall = new DepositAccount(pesho, 999m, 5.3m); IAccount depositAccComp = new DepositAccount(agroCompany, 11024m, 4.3m); List<IAccount> accounts = new List<IAccount>() { mortgageAccInd, mortgageAccComp, loanAccInd, loanAccComp, depositAccIndBig, depositAccIndSmall, depositAccComp }; foreach (var acc in accounts) { Console.WriteLine("{5} {0}: {1:N2}, {2:N2}, {3:N2}, {4:N2}", acc.GetType().Name, acc.CalculateRate(2), acc.CalculateRate(3), acc.CalculateRate(10), acc.CalculateRate(13), acc.Customer.GetType().Name); } }
private CustomerProfile FindProfile(IndividualCustomer customer, IList<CustomerProfile> profiles) { var selectedProfile = (from profile in profiles where customer.GetAge() >= profile.LowAge && customer.GetAge() <= profile.HighAge && profile.ChildernCount == customer.ChildernCount select profile).FirstOrDefault(); return selectedProfile; }
public static IndividualCustomer CreateIndividualCustomer(CountryCode country = CountryCode.SE) { IndividualCustomer iCustomer = null; switch (country) { case CountryCode.SE: iCustomer = Item.IndividualCustomer() .SetInitials("SB") .SetName("Tess", "Persson") .SetEmail("*****@*****.**") .SetPhoneNumber("0811111111") .SetIpAddress("123.123.123") .SetStreetAddress("Testgatan", "1") .SetBirthDate("19231212") .SetCoAddress("c/o Eriksson, Erik") .SetNationalIdNumber(DefaultTestIndividualNationalIdNumber) .SetZipCode("99999") .SetLocality("Stan"); break; case CountryCode.NO: iCustomer = Item.IndividualCustomer() .SetName("Ola", "Normann") .SetEmail("*****@*****.**") .SetPhoneNumber("21222222") .SetIpAddress("123.123.123") .SetStreetAddress("Testveien", "2") .SetNationalIdNumber("17054512066") .SetZipCode("359") .SetLocality("Oslo"); break; case CountryCode.FI: iCustomer = Item.IndividualCustomer() .SetName("Kukka-Maaria", "Kanerva Haapakoski") .SetEmail("*****@*****.**") .SetIpAddress("123.123.123") .SetStreetAddress("Atomitie", "2 C") .SetNationalIdNumber("160264-999N") .SetZipCode("370") .SetLocality("Helsinki"); break; case CountryCode.DK: iCustomer = Item.IndividualCustomer() .SetName("Hanne", "Jensen") .SetEmail("*****@*****.**") .SetPhoneNumber("22222222") .SetIpAddress("123.123.123") .SetStreetAddress("Testvejen", "42") .SetCoAddress("c/o Test A/S") .SetNationalIdNumber("2603692503") .SetZipCode("2100") .SetLocality("KØBENHVN Ø"); break; case CountryCode.DE: iCustomer = Item.IndividualCustomer() .SetName("Theo", "Giebel") .SetEmail("*****@*****.**") .SetIpAddress("123.123.123") .SetStreetAddress("Zörgiebelweg", "21") .SetCoAddress("c/o Test A/S") .SetNationalIdNumber("19680403") .SetZipCode("13591") .SetLocality("BERLIN"); break; case CountryCode.NL: iCustomer = Item.IndividualCustomer() .SetInitials("SB") .SetName("Sneider", "Boasman") .SetEmail("*****@*****.**") .SetPhoneNumber("999999") .SetIpAddress("123.123.123.123") .SetStreetAddress("Gate", "42") .SetBirthDate("19550307") .SetCoAddress("138") .SetNationalIdNumber("19550307") .SetZipCode("1102 HG") .SetLocality("BARENDRECHT"); break; default: throw new SveaWebPayException("Unsupported argument for method."); } return(iCustomer); }
public DepositAccount(IndividualCustomer pesho, int v1, decimal v2) { this.pesho = pesho; this.v1 = v1; this.v2 = v2; }
public static void Main() { Customer client1 = new IndividualCustomer( "7711240547", "Лазур 18бл.", "0886630111", "Николай", "Костадинов"); Customer client2 = new IndividualCustomer( "5165656515", "Изгрев 193бл.", "0886123456", "Христо", "Григоров"); Customer client3 = new CompanyCustomer( "1234567890", "пп Нефтохим", "+3598863710", "ИТСИБ ООД", "0123456789"); Customer client4 = new CompanyCustomer( "1234567890", "пп Нефтохим", "+3598863710", "ЛТСБ ООД", "0123456789"); IList<ICalculatable> accounts = new List<ICalculatable> { new DepositAccount( client1, 1200M, 0.05M), new DepositAccount( client3, 1200M, 0.05M), new LoanAccount( client2, 100000M, 0.01M), new LoanAccount( client4, 100000M, 0.02M), new MortgageAccount( client1, 100000M, 0.012M), new MortgageAccount( client3, 100000M, 0.012M), }; int ix = 0; foreach (Account account in accounts) { ix++; Console.WriteLine( "{0,-28} {1,-32} -> {2,13:C2}", account.ToString(), account.Awner.ToString(), account.CalculateInterestForPerion(12 + ix)); } }
/// <summary> /// Create a new IndividualCustomer object. /// </summary> /// <param name="customerID">Initial value of CustomerID.</param> /// <param name="accountNumber">Initial value of AccountNumber.</param> /// <param name="rowguid">Initial value of rowguid.</param> /// <param name="modifiedDate">Initial value of ModifiedDate.</param> public static IndividualCustomer CreateIndividualCustomer(int customerID, string accountNumber, global::System.Guid rowguid, global::System.DateTime modifiedDate) { IndividualCustomer individualCustomer = new IndividualCustomer(); individualCustomer.CustomerID = customerID; individualCustomer.AccountNumber = accountNumber; individualCustomer.rowguid = rowguid; individualCustomer.ModifiedDate = modifiedDate; return individualCustomer; }
static void Main() { // A bank holds different types of accounts for its customers: deposit accounts, loan accounts and // mortgage accounts. Customers could be individuals or companies. // All accounts have customer, balance and interest rate (monthly based). Deposit accounts are allowed // to deposit and with draw money. Loan and mortgage accounts can only deposit money. // All accounts can calculate their interest amount for a given period (in months). In the common case // its is calculated as follows: number_of_months * interest_rate. // Loan accounts have no interest for the first 3 months if are held by individuals and for the first 2 // months if are held by a company. // Deposit accounts have no interest if their balance is positive and less than 1000. // Mortgage accounts have ½ interest for the first 12 months for companies and no interest for the first // 6 months for individuals. // Your task is to write a program to model the bank system by classes and interfaces. You should identify // the classes, interfaces, base classes and abstract actions and implement the calculation of the interest // functionality through overridden methods. Thread.CurrentThread.CurrentCulture = new CultureInfo ("bg-BG"); var Dimitar = new IndividualCustomer (34334752, "Dimitar", "Petrov"); var Pipi = new IndividualCustomer (97203, "Pipi", "Topcheva"); var Gogo = new IndividualCustomer (34334752, "Gogo", "Petrov"); var Gana = new IndividualCustomer (97203, "Gana", "Pamukova"); var CorporateTroshikamak = new CorporateCustomer (891230, "Troshikamak Corporation"); var depositIC_Dimitar = new Deposit (Dimitar, 2500M, 1.0825M, 12); var depositIC_Gogo = new Deposit (Gogo, 500M, 1.0825M, 12); var loanIC_Gogo = new Loan (Gogo, 500M, 1.0825M, 2); var loanCC_CorporateTroshikamak = new Loan (CorporateTroshikamak, 1000000000M, 1.0931M, 36); var mortgageCC_CorporateTroshikamak = new Mortgage (CorporateTroshikamak, 1000000000M, 1.0931M, 6); var mortgageIC_Gana = new Mortgage (Gana, 100000M, 1.0875M, 7); var mortgageIC_Pipi = new Mortgage (Pipi, 100000M, 1.0875M, 3); List<Deposit> D_L = new List<Deposit> (); D_L.Add (depositIC_Dimitar); D_L.Add (depositIC_Gogo); List<Loan> L_L = new List<Loan> (); L_L.Add (loanIC_Gogo); L_L.Add (loanCC_CorporateTroshikamak); List<Mortgage> M_L = new List<Mortgage> (); M_L.Add (mortgageIC_Gana); M_L.Add (mortgageIC_Pipi); M_L.Add (mortgageCC_CorporateTroshikamak); Bank bank = new Bank (); bank.DepositAccountsList = D_L; bank.LoanAccountsList = L_L; bank.MortgageAccountsList = M_L; foreach (var item in bank.DepositAccountsList) { Console.WriteLine (item); Console.WriteLine (); } foreach (var item in bank.LoanAccountsList) { Console.WriteLine (item); Console.WriteLine (); } foreach (var item in bank.MortgageAccountsList) { Console.WriteLine (item); Console.WriteLine (); } }
static void Main() { Bank bank = new Bank("OOP"); // fill in some random records for (int i = 0; i < numberOfCustomers; i++) { Customer client; if(vladoRandoma.Next() % 2 == 0) { client = new Company(companyNames[vladoRandoma.Next(0, companyNames.Length)]); } else { client = new IndividualCustomer(fnames[i]+" "+ lnames[i]); } switch (vladoRandoma.Next() % 3) { case 1: bank.AddAccount(new Loan(client, vladoRandoma.Next(100, 10000), vladoRandoma.Next(0, 36))); break; case 2: bank.AddAccount(new Mortgage(client, vladoRandoma.Next(100, 10000), vladoRandoma.Next(0, 36))); break; case 0: bank.AddAccount(new Deposit(client, vladoRandoma.Next(100, 10000), vladoRandoma.Next(0, 36))); break; default: break; } } bank.PrintAccounts(); foreach (var item in bank.Customers) { bank[item.Name].Deposit(500); } foreach (var item in bank.Customers) { bank[item.Name].Draw(1000); } }