static void Main() { //Deposit test Console.WriteLine("Deposit account test:"); Deposit deposit = new Deposit(Customer.Individual, 2000m, 12.3m); Console.Write("Deposite interest for 3 months and 12.3 interest rate = "); Console.WriteLine(deposit.CalculateInterestAmount(3)); Console.WriteLine(); //Loan test Console.WriteLine("Loan account test:"); Loan loanIndividual = new Loan(Customer.Individual, 1000m, 1.2m); Loan loanCompany = new Loan(Customer.Company, 4000m, 3.3m); Console.Write("Individual interest for 4 months and 1.2 interest rate = "); Console.WriteLine(loanIndividual.CalculateInterestAmount(4)); Console.Write("Company interest for 3 months and 3.3 interest rate = "); Console.WriteLine(loanCompany.CalculateInterestAmount(3)); Console.WriteLine(); //Mortgage test Console.WriteLine("Mortgage account test:"); Mortgage mortgageIndividual = new Mortgage(Customer.Individual, 40000m, 5.4m); Mortgage mortgageCompany = new Mortgage(Customer.Company, 120000m, 6.5m); Console.Write("Individual interest for 4 months and {0} interest rate = ", mortgageIndividual.InterestRate); Console.WriteLine(mortgageIndividual.CalculateInterestAmount(4)); Console.Write("Individual interest for 15 months and 5.4 interest rate = "); Console.WriteLine(mortgageIndividual.CalculateInterestAmount(15)); Console.Write("Company interest for 3 months and 6.5 interest rate = "); Console.WriteLine(mortgageCompany.CalculateInterestAmount(3)); }
static void Main(string[] args) { //Pesho's Account Deposit peshosAccount = new Deposit(new Individual("Pesho"), 100000m, 25.3f); Console.WriteLine("Pesho's current balance: {0}", peshosAccount.Balance); Console.WriteLine("Pesho's interest amount: {0}", peshosAccount.CalculateInterestAmount(12)); //Add some money in the Pesho's account peshosAccount.Deposit(2131m); Console.WriteLine("Pesho's balance after the deposit: {0}", peshosAccount.Balance); peshosAccount.WithDraw(35000m); Console.WriteLine("Pesho's balance after the draw: {0}", peshosAccount.Balance); //Let us calculate the Pesho's interest amount Console.WriteLine("Pesho's account interest amount: {0}", peshosAccount.CalculateInterestAmount(4)); Console.WriteLine(); //Ivan's Account Account ivansAccount = new Loan(new Company("Ivan"), 1040.4m, 23.3f); Console.WriteLine("Ivan's interest amount: {0}", ivansAccount.CalculateInterestAmount(7)); Console.WriteLine(); //Dido's Account Account didosAccount = new Mortgage(new Individual("Dido"), 3422m, 5.4f); Console.WriteLine("Ivan's interest amount: {0}", didosAccount.CalculateInterestAmount(13)); }
static void Main() { Deposit deposit = new Deposit(new Individual("Phili Fry"), 5000m, 5); deposit.DepositIn(1000m); Console.WriteLine(deposit.Balance); deposit.Withdraw(1500m); Console.WriteLine(deposit.Balance); Console.WriteLine(deposit.CalculateInterest(5)); Console.WriteLine("-------------------"); Loan loan = new Loan(new Individual("James"), 2000m, 20); loan.DepositIn(2000m); Console.WriteLine(loan.Balance); Console.WriteLine(loan.CalculateInterest(5)); Console.WriteLine("-------------------"); Loan companyLoan = new Loan(new Company("Telecom"), 2000m, 20); companyLoan.DepositIn(3000m); Console.WriteLine(companyLoan.Balance); Console.WriteLine(companyLoan.CalculateInterest(5)); Console.WriteLine("-------------------"); Mortgage mortgage = new Mortgage(new Individual("Bart"), 2000m, 20); mortgage.DepositIn(3000m); Console.WriteLine(mortgage.Balance); Console.WriteLine(mortgage.CalculateInterest(8)); Console.WriteLine("-------------------"); Mortgage companyMortgate = new Mortgage(new Company("Airline"), 2000m, 20); Console.WriteLine(companyMortgate.CalculateInterest(16)); }
static void Main() { Console.WriteLine("Enter number"); int number = int.Parse(Console.ReadLine()); try { for (int count = 0; count < number; count++) { Console.WriteLine("Enter customer kind"); //true equals to individual, and false to company bool customerKind = bool.Parse(Console.ReadLine()); Console.WriteLine("Enter customer name"); string customerName = Console.ReadLine(); Customer customer = new Customer(customerKind, customerName); Console.WriteLine("Enter interest rate"); float currentInterestRate = float.Parse(Console.ReadLine()); Console.WriteLine("Enter account balance"); double currentBalance = double.Parse(Console.ReadLine()); Deposit deposit = new Deposit(customer, currentInterestRate, currentBalance); Loan loan = new Loan(customer, currentInterestRate, currentBalance); Mortgage mortgage = new Mortgage(customer, currentInterestRate, currentBalance); Console.WriteLine("Enter start month"); byte startMonth = byte.Parse(Console.ReadLine()); Console.WriteLine("Enter end month"); byte endMonth = byte.Parse(Console.ReadLine()); Console.WriteLine("Interest for the deposit is {0}", deposit.CalculateInterest(startMonth, endMonth)); Console.WriteLine("Interest for the loan is {0}", loan.CalculateInterest(startMonth, endMonth)); Console.WriteLine("Interest for the morgage is {0}", mortgage.CalculateInterest(startMonth, endMonth)); } } catch (ArgumentException ae) { Console.WriteLine(ae.Message); } }
private static void Main() { var deposit = new Deposit(400m, 0.01m, Customer.Individual); Console.WriteLine("Deposit Account: "); Console.WriteLine("Interest rate: " + deposit.CalculateRate(20)); deposit.DepositMoney(100000m); Console.WriteLine("Balance after depositing: " + deposit.Balance); Console.WriteLine("Interest rate: " + deposit.CalculateRate(20)); deposit.WithdrawMoney(100400m); Console.WriteLine("Balance after withdrawing: " + deposit.Balance); Console.WriteLine(); var mortgage = new Mortgage(500000m, 0.02m, Customer.Company); Console.WriteLine("Mortgage Account: "); Console.WriteLine("Interest rate for company: " + mortgage.CalculateRate(12)); mortgage.Customer = Customer.Individual; Console.WriteLine("Interest rate for individual: " + mortgage.CalculateRate(7)); Console.WriteLine(); var loan = new Loan(500000m, 0.02m, Customer.Company); Console.WriteLine("Loan Account: "); Console.WriteLine("Interest rate for company: " + loan.CalculateRate(24)); loan.Customer = Customer.Individual; Console.WriteLine("Interest rate for individual: " + loan.CalculateRate(3)); }
public void AddOrUpdate(GetMortgageInput input) { var config = new ConfigurationStore(new TypeMapFactory(), AutoMapper.Mappers.MapperRegistry.Mappers); var mapper = new MappingEngine(config); config.CreateMap<MortgageDto, Mortgage>().ConstructUsing(model => { if (model.Id == 0) { Mortgage toAdd = new Mortgage(); _mortgageRepository.Insert(toAdd); return toAdd; } else { return _mortgageRepository.Get(model.Id); } }).ForMember(x => x.LandProperty, o => o.Ignore()); try { mapper.Map<MortgageDto, Mortgage>(input.MortgageToUpdate); } catch (Exception e) { throw e; } }
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)); }
static void Main(string[] args) { //Facade Mortgage mortgage = new Mortgage(); //Evaluate mortage eligibility for customer Customer customer = new Customer("Joe Bloggs"); bool eligible = mortgage.IsEligible(customer, 125000); Console.WriteLine("\n" + customer.Name + " has been " + (eligible ? "Approved" : "Rejected")); // Wait for user Console.ReadKey(true); }
static void Main() { Console.WriteLine("This program tests the Bank project. It will run a few tests to determine if the code has been written correctly."); Console.WriteLine(); Individual ind1 = new Individual("Petar Atanasov"); Company comp1 = new Company("Telerik"); Deposit depInd = new Deposit(ind1, 500, 5, 12); Deposit depComp = new Deposit(comp1, 40000, 100, 6); Loan loanInd = new Loan(ind1, -5000, 50, 25); Loan loanComp = new Loan(comp1, -2000000, 1000, 20); Mortgage mortInd = new Mortgage(ind1, -50000, 150, 36); Mortgage mortComp = new Mortgage(comp1, -500000, 200, 48); Account[] accounts = { depInd, depComp, loanInd, loanComp, mortInd, mortComp }; foreach (var acc in accounts) { Console.WriteLine(acc.ToString()); Console.WriteLine("Interest amount is {0}", acc.InterestAmount()); Console.WriteLine(); } Console.Write("Press any key to continue testing:"); Console.ReadKey(); Console.WriteLine(); Console.WriteLine("Trying to deposit 100 in each account:"); foreach (var acc in accounts) { Console.WriteLine("Account balance before: {0}", acc.Balance); acc.Deposit(100); Console.WriteLine("Account balance after: {0}", acc.Balance); Console.WriteLine(); } Console.WriteLine("Withdrawing 200 from individual deposit:"); Console.WriteLine("Account balance before: {0}", depInd.Balance); depInd.Withdraw(200); Console.WriteLine("Account balance after: {0}", depInd.Balance); Console.WriteLine(); Console.WriteLine("Testing is complete."); }
public void Test() { var bank = A.Fake <IBank>(); var credit = A.Fake <ICredit>(); var loan = A.Fake <ILoan>(); A.CallTo(() => bank.SavingsAmount("John")).Returns(15m); A.CallTo(() => credit.IsGoodCreditHistory("John")).Returns(true); A.CallTo(() => loan.HasBadLoans("John")).Returns(true); var mortgage = new Mortgage(bank, credit, loan); mortgage.IsEligible("John", 100).Should().BeTrue(); mortgage.IsEligible("John", 200).Should().BeFalse(); }
static void Main() { // Facade var mortgage = new Mortgage(); var customer = new Customer { Name = "Lisa Johnson" }; // Evaluate mortgage eligibility for customer var eligible = mortgage.IsEligible(customer, 125000); Console.WriteLine("{0} has been {1}", customer.Name, eligible ? "Approved" : "Rejected"); Console.Write("Done."); Console.ReadLine(); }
public async Task ShouldRefundTotalAmountAsync() { Amount borrowedAmount = 10000; int duration = 120; decimal interestsRate = 1m; // Act Mortgage mortgage = await GenerateMortgageAsync(borrowedAmount, duration, interestsRate); // Assert Amount totalRefundedAmount = mortgage.Terms.Sum(t => t.AmortizedCapital); Assert.Equal((decimal)borrowedAmount, (decimal)totalRefundedAmount); }
public async Task LastTermShouldRefundAllCapitalAsync() { Amount borrowedAmount = 10000; // Arrange Mortgage mortgage = await GenerateMortgageAsync(borrowedAmount, 120, 1m); // Act mortgage.GenerateAmortizationTable(); // Assert Term lastTerm = mortgage.Terms.Last(); Term termBeforeLast = mortgage.Terms.ElementAt(mortgage.Terms.Count - 2); Assert.Equal(termBeforeLast.RemainingCapital, lastTerm.AmortizedCapital); }
public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Mortgage mortgage = unitOfWork.Mortgages.Get(id ?? default(int)); if (mortgage == null) { return(HttpNotFound()); } return(View(mortgage)); }
// Methods public Mortgage GetMortageDetails(int Id) { Mortgage mortgage = null; SiteUtilities utilities = new SiteUtilities(); string url = utilities.GetAppConfigValue("MortageApi") + "?id=" + Id; HttpResponseMessage message = new HttpService().PostResponse(url); if (message.IsSuccessStatusCode) { Task <string> task = message.Content.ReadAsStringAsync(); task.Wait(); mortgage = JsonConvert.DeserializeObject <Mortgage>(task.Result); } return(mortgage); }
static void Main() { // creating 3 different accounts Account acc1 = new Deposit(Custemer.Individual, 1234, 0.75m); Account acc2 = new Loan(Custemer.Companie, 100052, 1.2m); Account acc3 = new Mortgage(Custemer.Individual, 754, 0.98m); acc1.PrintBalance(); acc1.CalcInterest(7); acc1.PrintBalance(); acc1.Deposit(300); //acc1.Draw- it is Account Deposit acc4 = new Deposit(Custemer.Individual, 2222, 0.35m); acc4.Draw(1111); acc2.CalcInterest(7); acc2.Deposit(555); }
private static void ShowFacade() { Console.WriteLine("================================================"); Console.WriteLine("Pattern code (Facade):"); Facade facade = new Facade(); facade.MethodA(); facade.MethodB(); Console.WriteLine("\nReal code (Facade):"); Mortgage mortgage = new Mortgage(); Customer customer = new Customer("Ann McKinsey"); bool eligible = mortgage.IsEligible(customer, 125000); Console.WriteLine("\n" + customer.Name + " has been " + (eligible ? "Approved" : "Rejected")); }
// Methods public CalculateMortgageViewModel CalculateMortgage(Mortgage mortgage, int loanAmount, int loanTenure) { CalculateMortgageViewModel model = new CalculateMortgageViewModel(); int num = loanTenure * 12; decimal loanInterest = mortgage.InterestRate / 12; model.Mortgage = mortgage; model.LoanAmount = loanAmount; model.LoanTenure = loanTenure; decimal num3 = this.GetEmi(loanAmount, num, loanInterest); model.LoanEMI = num3; model.TotalLoan = num3 * num; model.TotalInterest = (num3 * num) - loanAmount; return(model); }
public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Mortgage mortgage = unitOfWork.Mortgages.Get(id ?? default(int)); if (mortgage == null) { return(HttpNotFound()); } ViewBag.fk_risk = new SelectList(unitOfWork.Risks.GetAll(), "id", "riskName", mortgage.fk_risk); return(View(mortgage)); }
private void PushHistoryInto(Mortgage testSubject) { var remainingCost = 155504.04; var monthlyPayment = 1990.59; var dtIncrement = testSubject.Inception.AddMonths(1); while (testSubject.GetValueAt(dtIncrement) > remainingCost.ToPecuniam()) { if (dtIncrement > DateTime.UtcNow.AddYears(30)) { break; } testSubject.AddNegativeValue(dtIncrement, monthlyPayment.ToPecuniam()); dtIncrement = dtIncrement.AddMonths(1); } }
private void btnCalculateMortgage_Click(object sender, EventArgs e) { if (valid()) { MortgageCalculatorServiceReference.MortgageCalculatorClient client = new MortgageCalculatorServiceReference.MortgageCalculatorClient("NetTcpBinding_IMortgageCalculator"); Mortgage objMortgage = new Mortgage(); objMortgage = client.ComputeMortgage(Convert.ToDouble(txtPurchasePrice.Text), Convert.ToDouble(txtInterestRate.Text), Convert.ToInt16(ddlAmortization.SelectedItem.ToString()), Convert.ToDouble(txtTaxes.Text), Convert.ToDouble(ddlPercentDown.SelectedItem.ToString())); txtDownPayment.Text = objMortgage.Down_Payment.ToString("c2"); txtRemainingMortgage.Text = objMortgage.Remaining_Mortgage.ToString("c2"); txtGePremium.Text = objMortgage.GE_Premium.ToString("c2"); txtTotalFinancing.Text = objMortgage.Total_Financing.ToString("c2"); txtMonthlyPayment.Text = objMortgage.Monthly_Mortgage_Payment.ToString("c2"); txtFees.Text = objMortgage.Fees.ToString("c2"); txtTotalPayment.Text = objMortgage.Total_Payment.ToString("c2"); } }
static void Main(string[] args) { Deposit deposit = new Deposit(new Individual("me", 123), 499, 0.1m, 2); Console.WriteLine(deposit.InterestRate); deposit.Deposit(10); Console.WriteLine(deposit.Balance); Loan myLoan = new Loan(new Company("MT", 11), 1000, 0.3m, 2); Console.WriteLine(myLoan.CalculateInterest()); var morgage = new Mortgage(new Individual("me again", 1), 1000, 0.1m, 7); Console.WriteLine(morgage.CalculateInterest()); morgage = new Mortgage(new Company("me ET", 1), 2000, 0.4m, 7); Console.WriteLine(morgage.CalculateInterest()); }
static void Main() { Person person1 = new Person("Cheplyat 4711, ul. Kriva 7", "+35930143285", "Georgi", "Nashmatliyski", 44, "7104254323"); Person person2 = new Person("Lovech 7611, ul. Prava 10", "+35940165883", "Kaymet", "Dertliev", 31, "8401055374"); Person person3 = new Person("Gudevitza 1691, ul. Glavna 1", "+35988765373", "Evlampi", "Svetlozarov", 52, "6401055374"); Company company1 = new Company("Sofia 1000, ul. Buren 23", "024446667", "Bastuni Unlimited EOOD", "Tenko Gazarliev", "BG237452357"); Company company2 = new Company("Sofia 1000, ul. Kiryak Stefchov 13", "026236305", "Kloshari Incorporated OOD", "Ceko Minev", "BG127722365"); Company company3 = new Company("Plovdiv 2030, ul. Tepe 5", "032481690", "ET Bass Tune", "Stamat Kazandjiev", "BG224711902"); Loan loan1 = new Loan(person1, -1000m, 0.12m); Loan loan2 = new Loan(company1, -20000m, 0.08m); Loan loan3 = new Loan(company2, -10010m, 0.10m); Mortgage mort1 = new Mortgage(person1, -100000m, 0.06m); Mortgage mort2 = new Mortgage(person2, -200000m, 0.05m); Mortgage mort3 = new Mortgage(person3, -50000m, 0.055m); Deposit deposit1 = new Deposit(person1, 500m, 0.02m); Deposit deposit2 = new Deposit(company3, 15000m, 0.02m); Deposit deposit3 = new Deposit(person3, 5500m, 0.02m); loan1.DepositMoney(1500); mort2.DepositMoney(15000); deposit3.WithdrawMoney(1000); int period = 2; // <<-- months; change the period to see how interest calculation differs according to the problem description Account[] allAccounts = { loan1, loan2, loan3, mort1, mort2, mort3, deposit1, deposit2, deposit3 }; foreach (var account in allAccounts) { Console.WriteLine("{2} {0} account\nCurrent Ballance = {1} BGN", account.Type, account.Ballance, account.Customer.Type); Console.WriteLine("Ballance in {0} months\n(Interest: {2:P}) = {1} BGN", period, account.CalcInterest(period), account.InterestRate); Console.WriteLine(new string('+', 50)); if (account.Customer is Person) { Person temp = (Person)account.Customer; Console.WriteLine("Owner: {0} {1} (EGN {2}), Age: {3}\nAddress: {4}\nPhone: {5}", temp.FirstName, temp.LastName, temp.EGN, temp.Age, temp.Address, temp.Phone); } else if (account.Customer is Company) { Company temp = (Company)account.Customer; Console.WriteLine("Company name: {0} (Bulstat: {1})\nMOL: {2}\nAddress: {3}\nPhone: {4}", temp.Name, temp.Bulstat, temp.MOL, temp.Address, temp.Phone); } Console.WriteLine(new string('=', 50)); } }
public ActionResult Edit(Mortgage std) { if (ModelState.IsValid) { // Loan Amount double l = std.LoanAmount; // Percentage double p = getPercentage(Convert.ToDouble(std.Interest)); // Terms int t = getTerms(std.TermsInYear); // Motgage double m = Math.Round(calculateMortgage(l, p, t), 2); //Total Principal double InterestandPrinciple = Math.Round(m, 2) * t; // Total Interest double Interest = Math.Round(InterestandPrinciple - l, 2); ViewBag.Mi = m; ViewBag.pi = InterestandPrinciple; ViewBag.ip = Interest; //Mortgage details DataTable d = MortgageDetails(l, p, t, m); List <DataRow> list = new List <DataRow>(); foreach (DataRow datarow in d.Rows) { list.Add(datarow); } ViewBag.List = list; return(View(std)); } return(View(std)); }
internal void FinDetailsMethod() { ExcelLib.PopulateInCollection(Base.ExcelPath, "FinancialDetails"); Driver.wait(2); //Verify the title of Webpage Assert.IsTrue(Driver.driver.PageSource.Contains("Purchase Price")); try { PurchasePrice.SendKeys(ExcelLib.ReadData(2, "PurchasePrice")); decimal d; if (decimal.TryParse(ExcelLib.ReadData(2, "PurchasePrice"), out d)) { Base.test.Log(RelevantCodes.ExtentReports.LogStatus.Pass, "Purchase Price field has been filled with integer"); Mortgage.SendKeys(ExcelLib.ReadData(2, "Mortgage")); decimal dM; if (decimal.TryParse(ExcelLib.ReadData(2, "Mortgage"), out d)) { Base.test.Log(RelevantCodes.ExtentReports.LogStatus.Pass, "Purchase Price field has been filled with integer"); Homevalue.SendKeys(ExcelLib.ReadData(2, "HomeValue")); Driver.wait(2); if (ClickNext.Enabled) { ClickNext.Click(); Base.test.Log(RelevantCodes.ExtentReports.LogStatus.Info, "Method to enter Financial details executed and mandatory fileds verified"); } else { Base.test.Log(RelevantCodes.ExtentReports.LogStatus.Fail, "Next button is not enabled"); } } else { Base.test.Log(RelevantCodes.ExtentReports.LogStatus.Fail, "Mortgage Field has been not been filled with numeric value"); } } else { Base.test.Log(RelevantCodes.ExtentReports.LogStatus.Fail, "Purchase Price field has not been filled with a numeric character"); } } catch (Exception ex) { string excepMesg = ex.Message; Base.test.Log(RelevantCodes.ExtentReports.LogStatus.Fail, "Exception Message:" + excepMesg); } }
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 ActionResult DeleteConfirmed(int id) { Mortgage mortgage = unitOfWork.Mortgages.Get(id); try { unitOfWork.Mortgages.Remove(mortgage); unitOfWork.Complete(); } catch (Exception e) { ViewBag.ErrorMessage = "Some Customer still reference on this Mortgage"; return(View("Error")); } return(RedirectToAction("Index")); }
/// <summary> /// Clears the Forms in the Property Form Fields /// </summary> private void ClearPropertyForm() { landAcquisitionCost.Clear(); AcquisitionLeasing.Clear(); Syndication.Clear(); LandTransfer.Clear(); LegalPurchaseLease.Clear(); Environmental.Clear(); Contigency.Clear(); Mortgage.Clear(); Construction.Clear(); Appraisal.Clear(); BCR.Clear(); MortgageLTV.Clear(); Interest25.Clear(); AnnualDebt.Clear(); }
static void Main(string[] args) { // Facade Mortgage mortgage = new Mortgage(); // Evaluate mortgage eligibility for customer Customer.Customer customer = new Customer.Customer("Ann McKinsey"); bool eligible = mortgage.IsEligible(customer, 125000); Console.WriteLine("\n" + customer.Name + " has been " + (eligible ? "Approved" : "Rejected")); // Wait for user Console.ReadKey(); }
internal void SaveFinanceDetails(int TestDataSet) { try { //Enter the testdata into the relevant input fields PurchasePrice.SendKeys(ExcelLib.ReadData(TestDataSet, "PurchasePrice")); Mortgage.SendKeys(ExcelLib.ReadData(TestDataSet, "Mortgage")); HomeValue.SendKeys(ExcelLib.ReadData(TestDataSet, "HomeValue")); Thread.Sleep(1000); //Click on the Next Button to move to the Tenant Details NextButton.Click(); } catch (Exception e) { Base.test.Log(RelevantCodes.ExtentReports.LogStatus.Error, "Error occured when entering Finance Details for the new property: " + e.Message.ToString()); } }
public IActionResult UpdateMortgage([FromBody] Mortgage mortgage) { if (mortgage == null || !ModelState.IsValid) { return(BadRequest(ModelState)); } if (!db.Mortgages.Any(x => x.Id == mortgage.Id)) { return(NotFound()); } db.Mortgages.Attach(mortgage); db.Entry(mortgage).State = EntityState.Modified; db.SaveChanges(); return(Ok(mortgage)); }
public void FinanceDetails() { //Enter Purchase Prise value PurchasePrice.SendKeys(ExcelLib.ReadData(2, "PurchasePrice")); Driver.wait(2000); //Enter Mortgage value Mortgage.SendKeys(ExcelLib.ReadData(2, "Mortgage")); Driver.wait(2000); //Enter Home Value HomeValue.SendKeys(ExcelLib.ReadData(2, "HomeValue")); Driver.wait(2000); //Clicking on next button NextFinance.Click(); Thread.Sleep(1000); }
static void Main() { Individual someone = new Individual(); Account someonesAccount = new Loan((decimal)123.54, (float)2.3, someone); someonesAccount.Deposit(20); Company someCompany = new Company(); Account someCompanyAccount = new Deposit((decimal)-1434.23, (float)4.5, someCompany); Console.WriteLine( someCompanyAccount.CalculateInterestAmount(13) ); Account someonesMortgageAcc = new Mortgage((decimal)1243.1, (float)45.3, someone); Console.WriteLine(someonesMortgageAcc.CalculateInterestAmount(7)); }
public static void Main() { Console.Title = "Problem 2. Bank of Kurtovo Konare"; Deposit goshoDeposit = new Deposit(Customer.Individuals, 1000m, 0.05m); goshoDeposit.DepositMoney(450); goshoDeposit.WithdrawMoney(400); Console.WriteLine(goshoDeposit + "Interest = " + goshoDeposit.CalculateInterest(10)); Console.WriteLine(); Loan carskiZaem = new Loan(Customer.Companies, 50000m, 0.1m); carskiZaem.DepositMoney(1); Console.WriteLine(carskiZaem + "Interest = " + carskiZaem.CalculateInterest(5)); Console.WriteLine(); Mortgage bmwPesho = new Mortgage(Customer.Individuals, 10000m, 0.01m); bmwPesho.DepositMoney(5000); Console.WriteLine(bmwPesho + "Interest = " + bmwPesho.CalculateInterest(30)); }
public Mortgage UpdateMortgage(int id, Mortgage mortgage) { if (!_db.Mortgages.Any(x => x.Id == id)) { throw new HttpResponseException(HttpStatusCode.NotFound); } if (ModelState.IsValid) { _db.Mortgages.Attach(mortgage); _db.Entry(mortgage).State = System.Data.EntityState.Modified; _db.SaveChanges(); } else { throw new HttpResponseException(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState)); } return(mortgage); }
public static void Main() { Deposit deposit = new Deposit(new Individual("Gosho", "Goshov", "Goshov"), 10M); deposit.DepositSum(2000); deposit.DrawSum(1000); Console.WriteLine(deposit.Customer.DisplayCustomersName()); Console.WriteLine("Interest amount for the deposit: {0:C2}\n", deposit.CalculateInterestForPeriod(2)); Loan loan = new Loan(new Individual("Pesho", "Peshov", "Peshov"), 100, 10M); Console.WriteLine(loan.Customer.DisplayCustomersName()); Console.WriteLine("Interest amount for the loan: {0:C2}\n", loan.CalculateInterestForPeriod(5)); Mortgage mortgage = new Mortgage(new Company("SAP"), 100, 10M); Console.WriteLine(mortgage.Customer.DisplayCustomersName()); Console.WriteLine("Interest amount for the mortgage: {0:C2}\n", mortgage.CalculateInterestForPeriod(4)); }
public bool CreateMortgage(MortgageDetail model, int id) { var entity = new Mortgage() { UserID = _userId, PropertyID = id, Interest = model.Interest, Period = model.Period, Payment = model.Payment, TotalLoanAmount = model.TotalLoanAmount, MonthlyPayment = model.MonthlyPayment, }; using (var ctx = new ApplicationDbContext()) { ctx.Mortgages.Add(entity); return(ctx.SaveChanges() == 1); } }
static void FacadeTester() { #region sample 1 var facade = new Facade(); facade.MethodA(); facade.MethodB(); #endregion #region sample 2 // Facade var mortgage = new Mortgage(); // Evaluate mortgage eligibility for customer var customer = new Customer("Ann McKinsey"); var eligible = mortgage.IsEligible(customer, 125000); Console.WriteLine("\n" + customer.Name + " has been " + (eligible ? "Approved" : "Rejected")); #endregion }
static void Main() { Deposite depositeIndividualStanimir = new Deposite(new Individual("Stanimir"), 2003, 5); Deposite depositeCompanyGeograficNational = new Deposite(new Company("GeograficNational"), 198032, 17); Loan loanIndividualGerasim = new Loan(new Individual("Gerasim"), 315, 2); Loan loanCompanyTouristOOD = new Loan(new Company("TouristOOD"), 43707, 9); Mortgage mortgageIndividualPetkan = new Mortgage(new Individual("Petkan"), 200, 6); Mortgage mortgageCompanySoftCom = new Mortgage(new Company("SoftCom"), 299387, 19); Console.WriteLine(new string('-', 80)); Bank alianzBank = new Bank("Alianz"); alianzBank.AddAccount(depositeIndividualStanimir); alianzBank.AddAccount(depositeCompanyGeograficNational); alianzBank.AddAccount(loanIndividualGerasim); alianzBank.AddAccount(loanCompanyTouristOOD); alianzBank.AddAccount(mortgageIndividualPetkan); alianzBank.AddAccount(mortgageCompanySoftCom); Console.WriteLine(alianzBank.ToString()); }
private MortgageCalculationModel CalculateMortgageModel(Mortgage m, Purchase p) { var model = new MortgageCalculationModel(); var rate = (double)m.InterestRate / 100 / 12; var principal = -FinancialFunctions.PPMT(rate, 1, m.LoanAmortizationTerm, p.LoanAmount, 0, 0); var interestPayment = -FinancialFunctions.IPMT(rate, 1, m.LoanAmortizationTerm, p.LoanAmount, 0, 0); model.Interest = interestPayment; model.Principle = principal; if (p.DownPaymentPercentage < 20) { model.PMI = (p.LoanAmount * ((0.4) / 100)) / 12; return(model); } return(model); }
static void Main(string[] args) { //Testar uppkopplingen mot GitHub // MorgageEligibility // Facade var mortgage = new Mortgage(); var customer = new Customer("BO", "LEANDERSON"); var amount = 125000.0; //Invoke the facade and the facade invokes all of it's subsystem. var isEligible = mortgage.IsEligible(customer, amount); System.Console.WriteLine( "=> {0} {1}s application for a loan of {2} has been {3}.", customer.FirstName, customer.LastName, amount, (isEligible ? "approved" : "rejected")); System.Console.ReadLine(); }
public IHttpActionResult Post(Mortgage mortgage) { if (mortgage.LoanAmount == 0 || mortgage.TermsInMonths == 0) { var resp = new HttpResponseMessage(System.Net.HttpStatusCode.NotFound) { Content = new StringContent("Mortgage loan amount or duration cannot be 0"), ReasonPhrase = "Mortgage loan amount or duration cannot be 0" }; throw new HttpResponseException(resp); } var mortgageResponseObject = mortgageService.CalculateMortgage(mortgage); if (mortgageResponseObject == null) { return(NotFound()); } return(Ok(mortgageResponseObject)); }
static void Main(string[] args) { try { Deposit deposit = new Deposit(Customer.Company, 20000m, 3.4m); deposit.Withdraw(345m); deposit.DepositMoney(1000m); deposit.CalculateInterest(10); Console.WriteLine("Deposit:\n{0}", deposit); Loan loanIndividual = new Loan(Customer.Individual, 1000m, 20m); loanIndividual.DepositMoney(3000m); loanIndividual.CalculateInterest(5); Console.WriteLine("Loan individual:\n{0}", loanIndividual); Loan loanCompalny = new Loan(Customer.Company, 200000m, 5m); loanCompalny.DepositMoney(30000m); loanCompalny.CalculateInterest(4); Console.WriteLine("Loan company:\n{0}", loanCompalny); Mortgage mortageIndividual = new Mortgage(Customer.Individual, 500, 3.3m); mortageIndividual.DepositMoney(200m); mortageIndividual.CalculateInterest(7); Console.WriteLine("Mortage individual:\n{0}", mortageIndividual); Mortgage mortageCompany = new Mortgage(Customer.Company, 50000, 4m); mortageIndividual.DepositMoney(2000m); mortageIndividual.CalculateInterest(13); Console.WriteLine("Mortage individual:\n{0}", mortageIndividual); } catch (OverflowException ex) { Console.WriteLine(ex.Message); } catch (ArgumentOutOfRangeException ex) { Console.WriteLine(ex.Message); } }
static void Main(string[] args) { // MortgageEligibility // Facade var mortgage = new Mortgage(); var customer = new Customer("Harry", "Hederlig"); var amount = 125000.0; // Invoke the facade and the facade invokes all of it´s subsystems. var isEligible = mortgage.IsEligible(customer, amount); System.Console.WriteLine( "=> {0}{1}s application for loan of {2} has been {3}.", customer.FirstName, customer.LastName, amount, (isEligible ? "approved" : "rejected")); System.Console.ReadLine(); }
public void Mortgage__ShouldLoadAValidMortgage() { var mortgage = new Mortgage() { MortgageId = 9, InterestRate = 1, Name = "test" }; mockRepositoryMortgage = new Mock <IRepositoryBase <Mortgage> >(); mockRepositoryMortgage.Setup(m => m.GetId(9)).Returns(mortgage); MortgageController controller = new MortgageController(mockRepositoryMortgage.Object); ViewResult result = controller.Details(9) as ViewResult; var viewModel = controller.ViewData.Model as Mortgage; Assert.IsNotNull(result); Assert.IsNotNull(viewModel); Assert.IsTrue(viewModel.MortgageId == mortgage.MortgageId); Assert.AreEqual(viewModel, mortgage); Assert.AreSame(viewModel, mortgage); }
private Mortgage GetTestSubject() { var purchaseDate = new DateTime(2008, 12, 1); var purchasePrice = 393291.02; var rate = 0.02f; var addr = new PostalAddress(); var addrData = new AddressData { ThoroughfareNumber = "123", Locality = "abc", PostalCode = "99999", ThoroughfareName = "lmnop", ThoroughfareType = "st" }; addr.CityArea = new UsCityStateZip(addrData); addr.Street = new UsStreetPo(addrData); var testSubject = new Mortgage(addr, purchaseDate, rate, purchasePrice.ToPecuniam()); return(testSubject); }
static void Main() { Customer pesho = new Individual("Pesho"); Customer firmataNaPesho = new Company("Pesho Inc"); Account loan1 = new Loan(pesho,12.2M); Account loan2 = new Loan(firmataNaPesho, 12.2M); loan1.DepositMoney(1000M); loan2.DepositMoney(1000M); System.Console.WriteLine(string.Format("Loan {0}. Interest amount: {1:C}", loan1.Customer.Name, loan1.CalculateInterestAmount(24))); System.Console.WriteLine(string.Format("Loan {0}. Interest amount: {1:C}", loan2.Customer.Name, loan2.CalculateInterestAmount(24))); Account deposit1 = new Deposit(pesho, 13M); Account deposit2 = new Deposit(firmataNaPesho, 13M); deposit1.DepositMoney(15M); deposit2.DepositMoney(2000M); System.Console.WriteLine(string.Format( "Deposit {0}. Interest amount: {1:C}", deposit1.Customer.Name, deposit1.CalculateInterestAmount(24))); System.Console.WriteLine(string.Format( "Deposit {0}. Interest amount: {1:C}", deposit2.Customer.Name, deposit2.CalculateInterestAmount(24))); Account mortage1 = new Mortgage(pesho, 10.2M); Account mortage2 = new Mortgage(firmataNaPesho , 10.2M); mortage1.DepositMoney(200M); mortage2.DepositMoney(200M); System.Console.WriteLine(string.Format( "Mortage {0}. Interest amount: {1:C}", mortage1.Customer.Name, mortage1.CalculateInterestAmount(24))); System.Console.WriteLine(string.Format( "Mortage {0}. Interest amount: {1:C}", mortage2.Customer.Name, mortage2.CalculateInterestAmount(24))); }
static void Main() { // Innstance of an individual and a Company customer Customer cust1 = new Individual("Misho", "Sofia", "541010"); Customer cust2 = new Company("Albireo", "Plovdiv", "BG1211121121"); // Deposit account-Individual customer Deposit account01 = new Deposit(cust1, 0.5); Console.WriteLine("Open new deposit for Individual. Starting ammount ->{0}", account01.Balance); account01.DepositMoney(1500); Console.WriteLine("Deposit 1500. Ammount ->{0}", account01.Balance); account01.WithdrawMoney(400); Console.WriteLine("Withdraw 400. Ammount ->{0}", account01.Balance); account01.CalculateInterest(5); Console.WriteLine("Calculate interest of {1}% for 5 months. Ammount ->{0}", account01.Balance, account01.InterestRate); account01.WithdrawMoney(600); Console.WriteLine("Withdraw 600. Ammount ->{0}", account01.Balance); account01.CalculateInterest(3); // 0% interest when balance is below 1000 Console.WriteLine("Calculate interest of {1}% for 3 months. Ammount ->{0}", account01.Balance, account01.InterestRate); Console.WriteLine(); //Loan account - Company Loan account02 = new Loan(cust2, 11000, 1); Console.WriteLine("Open new loan for a company. Ammount -> {0}", account02.Balance); account02.DepositMoney(3000); Console.WriteLine("Deposit 3000. Ammount -> {0}", account02.Balance); account02.CalculateInterest(2); // 0% interest or the first 2 months Console.WriteLine("Calculate interest of {1}% for 2 months. Ammount ->{0}", account02.Balance, account02.InterestRate); account02.CalculateInterest(5); Console.WriteLine("Calculate interest of {1}% for 5 months. Ammount ->{0}", account02.Balance, account02.InterestRate); Console.WriteLine(); //Loan Account - Individual Loan account03 = new Loan(cust1, 1000, 1.2); Console.WriteLine("Open new loan for an individual. Ammount -> {0}", account03.Balance); account03.DepositMoney(100); Console.WriteLine("Deposit 100. Ammount -> {0}", account03.Balance); // 0% interest or the first 3 months account03.CalculateInterest(3); Console.WriteLine("Calculate interest of {1}% for 3 months. Ammount ->{0}", account03.Balance, account03.InterestRate); account03.CalculateInterest(5); Console.WriteLine("Calculate interest of {1}% for 5 months. Ammount ->{0}", account03.Balance, account03.InterestRate); Console.WriteLine(); //Mortgage account - Individual Mortgage account04 = new Mortgage(cust1, 50000, 0.6); Console.WriteLine("Open new mortgage for an individual. Ammount -> {0}", account04.Balance); // 0% interest or the first 6 months account04.CalculateInterest(6); Console.WriteLine("Calculate interest of {1}% for 6 months. Ammount ->{0}", account04.Balance, account04.InterestRate); account04.CalculateInterest(7); Console.WriteLine("Calculate interest of {1}% for 7 months. Ammount ->{0}", account04.Balance, account04.InterestRate); account04.DepositMoney(1500); Console.WriteLine("Deposit 1500. Ammount -> {0}", account04.Balance); Console.WriteLine(); // Mortgage account - Company Mortgage account05 = new Mortgage(cust2, 500000, 0.4); Console.WriteLine("Open new mortgage for a company. Ammount -> {0}", account05.Balance); account05.CalculateInterest(10); Console.WriteLine("Calculate interest of {1}% for 10 months. Ammount ->{0}", account05.Balance, account05.InterestRate); account05.CalculateInterest(15); Console.WriteLine("Calculate interest of {1}% for 15 months. Ammount ->{0}", account05.Balance, account05.InterestRate); account05.DepositMoney(5000); Console.WriteLine("Deposit 5000. Ammount -> {0}", account05.Balance); }
public void AddOrUpdate(UpdateLandPropertyInput input) { var config = new ConfigurationStore(new TypeMapFactory(), AutoMapper.Mappers.MapperRegistry.Mappers); var mapper = new MappingEngine(config); config.CreateMap<LandPropertyDto, LandProperty>().ConstructUsing(model => { if (model.Id == 0) { LandProperty toAdd = new LandProperty(); _landPropertyRepository.InsertAsync(toAdd); return toAdd; } else { return _landPropertyRepository.Get(model.Id); } }); config.CreateMap<LandPropertyOwnerDto, Owner>().ConstructUsing(model => { return _ownerRepository.Get(model.Id); }); config.CreateMap<MortgageDto, Mortgage>().ConstructUsing(model => { if (model.MortgageIdentifier > 0 && model.Id == 0) { Mortgage toAdd = new Mortgage(); _mortgageRepository.Insert(toAdd); return toAdd; } else if (model.Id > 0) { return _mortgageRepository.Get(model.Id); } else { return null; } }).ForMember(x => x.LandProperty, o => o.Ignore()); try { mapper.Map<LandPropertyDto, LandProperty>(input.LandPropToUpdate); } catch (Exception e) { throw e; } }