public string sendMail(MortgageModel model) { try { client = new SmtpClient(); client.DeliveryMethod = SmtpDeliveryMethod.Network; client.EnableSsl = true; client.Host = host; client.Port = port; System.Net.NetworkCredential credentials = new System.Net.NetworkCredential(from, pass); client.UseDefaultCredentials = false; client.Credentials = credentials; mailMessage = new MailMessage(); mailMessage.To.Add(to); mailMessage.From = new MailAddress(from); mailMessage.Subject = subject; mailMessage.IsBodyHtml = true; prepbody(model); mailMessage.Body = body; client.Send(mailMessage); return("E-mail sent!"); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine("Could not send the e-mail - error: " + ex.Message); return("Could not send the e-mail"); } }
public void prepbody(MortgageModel model) { body += "<h2>Mortgage Calculator</h2>"; body += @"<table> <tr> <td>Date</td> <td colspan ='2'>" + model.Date + @"</td> </tr> <tr> <td>Mortgage Amount</td> <td>$</td> <td>" + model.Principal + @"</td> </tr> <tr> <td>Amortization </td> <td>Years</td> <td>" + model.Years + @"</td> </tr> <tr> <td>Interest Rate</td> <td>%</td> <td>" + model.Rate + @"</td> </tr> <tr> <td> Monthly</td> <td>$</td> <td>" + model.Monthly + @"</td> </tr> </table>"; }
public List <MortgageModel> GetHistory() { List <MortgageModel> list = new List <MortgageModel>(); SqlConnection con = new SqlConnection(con_string()); con.Open(); SqlCommand cmd = new SqlCommand(); cmd.Connection = con; cmd.CommandText = "select * from history"; SqlDataReader reader = cmd.ExecuteReader(); if (reader.HasRows) { while (reader.Read()) { MortgageModel temp = new MortgageModel(); temp.Id = reader.GetInt32(0); temp.Date = reader.GetDateTime(1); temp.Principal = reader.GetInt32(2); temp.Rate = reader.GetDecimal(3); temp.Years = reader.GetInt32(4); temp.Monthly = reader.GetDecimal(5); list.Add(temp); } } con.Close(); return(list); }
public int Update(MortgageModel model) { string query = "update history update principal ='" + model.Principal + "' rate='" + model.Rate + "' years='" + model.Years + "' monthly='" + model.Monthly + "' where id='" + model.Id + "'"; return(EUpdate(query)); }
public int Insert(MortgageModel model) { string query = "insert into history (date, principal, rate, years, monthly) values('" + DateTime.Now + "','" + model.Principal + "','" + model.Rate + "'," + model.Years + ",'" + model.Monthly + "')"; return(EUpdate(query)); }