Exemplo n.º 1
0
        public IActionResult AddParamter(Loan loan)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            loanService.AddLoan(loan);
            return(NoContent());
        }
Exemplo n.º 2
0
        public ActionResult RequestLoan(Loan loan)
        {
            if (ModelState.IsValid)
            {
                if (LoanService.AddLoan(loan))
                {
                    return(RedirectToAction("Index", new { username = loan.Username }));
                }
            }

            return(RedirectToAction("RequestLoan", new { username = loan.Username }));
        }
Exemplo n.º 3
0
        public static void Main(string[] args)
        {
            int             indication = 1;
            List <UnitFlow> fullList   = new List <UnitFlow>();
            Loan            loan       = new Loan();

            while (indication > 0)
            {
                Console.Write("Please enter in your loan amount: ");
                string amount1 = Console.ReadLine();
                loan.Amount = decimal.Parse(amount1);

                Console.Write("Please enter in your loan duration: ");
                string duration1 = Console.ReadLine();
                loan.Duration = Int32.Parse(duration1);

                Console.Write("Please enter in your interest rate: ");
                string r1 = Console.ReadLine();
                loan.Rate = decimal.Parse(r1);

                LoanService.AddLoan(loan);

                UnitFlow unitFlow = Calculator.CalculateCashflow(loan);
                fullList.Add(unitFlow);


                Console.WriteLine("Month\t\tInterest\tPrincipal\tRemaining Balance");
                foreach (var row in unitFlow.Unit)
                {
                    Console.WriteLine(row.Month + "\t\t" + Math.Round(row.InterestPayment, 2) + "\t\t" +
                                      Math.Round(row.PrincipalPayment, 2) + "\t\t" + Math.Round(row.RemainingBalance, 2));
                }

                Console.Write("Would you want to enter another one? yes(1)/no(0)");
                indication = int.Parse(Console.ReadLine());
            }

            UnitFlow pool = new UnitFlow();

            pool = Calculator.CalculatePoolCashflow(fullList);

            Console.WriteLine("Month\t\tInterest\tPrincipal\tRemaining Balance");
            foreach (var row in pool.Unit)
            {
                Console.WriteLine(row.Month + "\t\t" + Math.Round(row.InterestPayment, 2) + "\t\t" +
                                  Math.Round(row.PrincipalPayment, 2) + "\t\t" + Math.Round(row.RemainingBalance, 2));
            }
        }
        //public static void HandleAccountManagerMenu(string suboption)
        //{
        //    if (suboption.Equals("0"))
        //    {
        //        return;
        //    }
        //    else if (suboption.Equals("1"))
        //    {
        //        Auth.CreateManager();
        //        HandleSubMenu("2");

        //    }
        //    else if (suboption.Equals("2"))
        //    {
        //        if (Auth.isManagerLoggedIn)
        //        {

        //            ShowLoggedInManagerMenu();
        //            string miniOption = Console.ReadLine();

        //            if (miniOption.Equals("0"))
        //            {
        //                Auth.LogoutAccountManager();
        //                HandleSubMenu("1");
        //            }
        //            else
        //            {
        //                ShowLoggedInManagerMenu();

        //            }
        //        }
        //        else
        //        {
        //            Auth.LoginAccountManager();
        //            ShowLoggedInManagerMenu();
        //            string option = Console.ReadLine();
        //            HandleLoggedInManagerOperations(option);
        //        }
        //    }
        //    else
        //    {
        //        throw new Exception("input not recognized");
        //    }

        //}

        public static void HandleLoanMenu(string option)
        {
            double loanAmount;
            string loanType = string.Empty;
            bool   isError  = false;

            try
            {
                if (option.Equals("1"))
                {
                    loanAmount = 100000;
                    loanType   = "House";
                }

                else if (option.Equals("2"))
                {
                    loanAmount = 500000;
                    loanType   = "car";
                }

                else if (option.Equals("3"))
                {
                    loanAmount = 1000000;
                    loanType   = "Business";
                }

                else
                {
                    isError = true;
                    throw new Exception("Input not recognized.");
                }
                if (!isError)
                {
                    loanService.AddLoan(AccountHolderService.loggedInAccountHolder.Id, loanAmount, loanType);
                    Console.WriteLine($"You Have Succesfully Being Grant A Loan Of {loanType} of {loanAmount}");
                }
            }
            catch (Exception e)
            {
                Console.WriteLine($"Error: {e.Message}");
            }
            finally
            {
                ShowContinueMenu();
                HandleAccountHolderMenu("2");
            }
        }