public void Can_Create_Quote() { var testQuote = "Test quote"; var testAuthor = "test author"; var quote = Quote.BuildQuote(testQuote, testAuthor); Assert.That(quote.QuoteText, Is.EqualTo(testQuote)); Assert.That(quote.Author, Is.EqualTo(testAuthor)); }
public ActionResult GetQuote(int customerID, DateTime dob, bool dui, int tickets, int year, string make, string model, bool fullCoverage) { // CustomerID and DOB are passed from StartQuote to View to GetQuote // These are the only Customer props that a Quote needs // This avoids storing some kind of session on server // Bad practice, but works Quote quote = new Quote() { CustomerID = customerID, QuoteDateTime = DateTime.Now, CarYear = year, CarMake = make, CarModel = model, DUI = dui, Tickets = tickets, FullCoverage = fullCoverage, }; // after quote object is created, BuildQuote() takes in the DOB and calculates the quote quote.BuildQuote(dob); // Add the Quote to the DB string queryString = @"Insert into Quotes (CustomerID, QuoteDateTime, CarYear, CarMake, CarModel, DUI, Tickets, FullCoverage, QuotePrice) VALUES (@CustomerID, @QuoteDateTime, @CarYear, @CarMake, @CarModel, @DUI, @Tickets, @FullCoverage, @QuotePrice)"; using (SqlConnection connection = new SqlConnection(_connectionString)) { SqlCommand command = new SqlCommand(queryString, connection); command.Parameters.Add("@CustomerID", SqlDbType.Int); command.Parameters.Add("@QuoteDateTime", SqlDbType.DateTime); command.Parameters.Add("@CarYear", SqlDbType.Int); command.Parameters.Add("@CarMake", SqlDbType.VarChar); command.Parameters.Add("@CarModel", SqlDbType.VarChar); command.Parameters.Add("@DUI", SqlDbType.Bit); command.Parameters.Add("@Tickets", SqlDbType.Int); command.Parameters.Add("@FullCoverage", SqlDbType.Bit); command.Parameters.Add("@QuotePrice", SqlDbType.Float); command.Parameters["@CustomerID"].Value = quote.CustomerID; command.Parameters["@QuoteDateTIme"].Value = quote.QuoteDateTime; command.Parameters["@CarYear"].Value = quote.CarYear; command.Parameters["@CarMake"].Value = quote.CarMake; command.Parameters["@CarModel"].Value = quote.CarModel; command.Parameters["@DUI"].Value = quote.DUI; command.Parameters["@Tickets"].Value = quote.Tickets; command.Parameters["@FullCoverage"].Value = quote.FullCoverage; command.Parameters["@QuotePrice"].Value = quote.QuotePrice; connection.Open(); command.ExecuteNonQuery(); connection.Close(); } return(View("ShowQuote", quote)); }
public static async Task <byte[]> BuildQuote() { return(await Quote.BuildQuote()); }