public ActionResult Quote( string first, string last, int year, int tickets, string day, string month, int birthYear, string make, string model, string fullCoverage, string dui, string email) { CustomerConfirm customerConfirm = new CustomerConfirm() { First = first, Last = last, BirthYear = birthYear, Day = day, Dui = dui, Email = email, FullCoverage = fullCoverage, Make = make, Model = model, Month = month, Year = year, Tickets = tickets }; return(View(customerConfirm)); }
public ActionResult Submit(CustomerConfirm customerConfirm) { string connectionString = @"Data Source=LAPTOP-F7SSE5AO\SQLEXPRESS;Initial Catalog=db_QuotesIssued;Integrated Security=True;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False"; string insertString = @"INSERT INTO quotes ( firstName, lastName, email, dob, carYear, carMake, carModel, dui, tickets, fullCoverage, finalQuote ) VALUES ( @firstName, @lastName, @email, @dob, @carYear, @carMake, @carModel, @dui, @tickets, @fullCoverage, @finalQuote )"; using (SqlConnection connection = new SqlConnection(connectionString)) { SqlCommand sqlCommand = new SqlCommand(insertString, connection); sqlCommand.Parameters.Add("@firstName", SqlDbType.VarChar); sqlCommand.Parameters.Add("@lastName", SqlDbType.VarChar); sqlCommand.Parameters.Add("@email", SqlDbType.VarChar); sqlCommand.Parameters.Add("@dob", SqlDbType.VarChar); sqlCommand.Parameters.Add("@carYear", SqlDbType.Int); sqlCommand.Parameters.Add("@carMake", SqlDbType.VarChar); sqlCommand.Parameters.Add("@carModel", SqlDbType.VarChar); sqlCommand.Parameters.Add("@dui", SqlDbType.VarChar); sqlCommand.Parameters.Add("@tickets", SqlDbType.Int); sqlCommand.Parameters.Add("@fullCoverage", SqlDbType.VarChar); sqlCommand.Parameters.Add("@finalQuote", SqlDbType.Float); sqlCommand.Parameters["@firstName"].Value = customerConfirm.First; sqlCommand.Parameters["@lastName"].Value = customerConfirm.Last; sqlCommand.Parameters["@email"].Value = customerConfirm.Email; sqlCommand.Parameters["@dob"].Value = customerConfirm.Month + "/" + customerConfirm.Day + "/" + customerConfirm.BirthYear.ToString(); sqlCommand.Parameters["@carYear"].Value = customerConfirm.Year; sqlCommand.Parameters["@carMake"].Value = customerConfirm.Make; sqlCommand.Parameters["@carModel"].Value = customerConfirm.Model; sqlCommand.Parameters["@dui"].Value = customerConfirm.Dui; sqlCommand.Parameters["@tickets"].Value = customerConfirm.Tickets; sqlCommand.Parameters["@fullCoverage"].Value = customerConfirm.FullCoverage; sqlCommand.Parameters["@finalQuote"].Value = customerConfirm.Total; connection.Open(); sqlCommand.ExecuteNonQuery(); connection.Close(); } return(View(customerConfirm)); }