예제 #1
0
        public static void Log(MortgageInfo mortgageInfo, MortgageResult mortgageResult)
        {
            SqlConnection connection = Connect();

            SqlCommand cmd = new SqlCommand($"INSERT INTO {TableName} VALUES(@principle, @time, @rate, @years, @monthlyPayment)",
                                            connection);

            cmd.Parameters.AddWithValue("principle", mortgageInfo.Principle);
            cmd.Parameters.AddWithValue("time", DateTime.Now.Ticks);
            cmd.Parameters.AddWithValue("rate", mortgageInfo.InterestRate);
            cmd.Parameters.AddWithValue("years", mortgageInfo.DurationYears);

            cmd.Parameters.AddWithValue("monthlyPayment", mortgageResult.MonthlyPayment);

            cmd.ExecuteNonQuery();

            connection.Close();
        }
예제 #2
0
        public ActionResult Index(double Cost, double Principle, double InterestRate, int DurationYears)
        {
            MortgageInfo mortgageInfo = new MortgageInfo(Cost, Principle, InterestRate, DurationYears);

            MortgageResult mortgageResult = new MortgageResult {
                MonthlyPayment = MortgageLib.MonthlyPayment(mortgageInfo)
            };

            // Saving the results to a database.
            {
                MortgageLoggerSQL.TryCreateTables(); // Yes, I am too lazy to run this at the start of the program. Let's just do it here.

                MortgageLoggerSQL.Log(mortgageInfo, mortgageResult);
            }


            return(View("IndexResult", mortgageResult));
        }
예제 #3
0
 public static double MonthlyPayment(MortgageInfo m)
 {
     return(MonthlyPayment(m.Principle, m.InterestRate, m.DurationYears));
 }