// GET: Admin public ActionResult Index() { List <QuoteVm> Quotes = new List <QuoteVm>(); using (SqlConnection connection = new SqlConnection(connectionString)) { using (SqlCommand command = new SqlCommand(@"PROC_Get_User_Premiums", connection)) { command.CommandType = CommandType.StoredProcedure; connection.Open(); SqlDataReader sql = command.ExecuteReader(); while (sql.Read()) { QuoteVm quote = new QuoteVm(); quote.Id = int.Parse(sql["id"].ToString()); quote.FirstName = sql["FirstName"].ToString(); quote.LastName = sql["LastName"].ToString(); quote.Email = sql["Email"].ToString(); quote.Premium = decimal.Parse(sql["Premium"].ToString()); Quotes.Add(quote); } sql.Close(); } connection.Close(); } return(View(Quotes)); }
// GET: Admin public ActionResult Index() { using (InsuranceQuotesEntities db = new InsuranceQuotesEntities()) { var quotes = db.Quotes.ToList(); var quoteVms = new List <QuoteVm>(); foreach (var quote in quotes) { var quoteVm = new QuoteVm(); quoteVm.Id = quoteVm.Id; quoteVm.FirstName = quote.FirstName; quoteVm.LastName = quote.LastName; quoteVm.EmailAddress = quote.EmailAddress; quoteVm.DateOfBirth = quote.DateOfBirth.Value; quoteVm.CarYear = quote.CarYear; quoteVm.CarMake = quote.CarMake; quoteVm.CarModel = quote.CarModel; quoteVm.DUIStatus = quote.DUIStatus; quoteVm.SpeedingTicketNum = Convert.ToInt32(quote.SpeedingTicketNum); quoteVm.TypeOfCoverage = quote.TypeOfCoverage; quoteVm.CustomerQuote = quote.CustomerQuote; quoteVms.Add(quoteVm); } return(View(quoteVms)); } }
public ActionResult Admin() { using (QuoteDbEntities db = new QuoteDbEntities()) { var quotes = db.QuoteTables; var quoteVms = new List <QuoteVm>(); foreach (var quote in quotes) { var quoteVm = new QuoteVm(); quoteVm.FirstName = quote.FirstName; quoteVm.LastName = quote.LastName; quoteVm.EmailAddress = quote.EmailAddress; quoteVm.Quote1 = Convert.ToDecimal(quote.Quote1); quoteVms.Add(quoteVm); } return(View(quoteVms)); } }
public ActionResult Admin() { using (CarInsuranceEntities db = new CarInsuranceEntities()) { var quotes = db.Quotes; var quoteVms = new List <QuoteVm>(); foreach (var quote in quotes) { var quoteVm = new QuoteVm(); quoteVm.FirstName = quote.FirstName; quoteVm.LastName = quote.LastName; quoteVm.EmailAddress = quote.EmailAddress; quoteVm.InsuranceQuote = quote.InsuranceQuote; quoteVms.Add(quoteVm); } return(View(quoteVms)); } }
// GET: Admin public ActionResult Index() { using (InsuranceEntities db = new InsuranceEntities()) { var insurees = db.Insurees; var quoteVms = new List <QuoteVm>(); foreach (var insuree in insurees) { var quoteVm = new QuoteVm(); quoteVm.FirstName = insuree.FirstName; quoteVm.LastName = insuree.LastName; quoteVm.EmailAddress = insuree.EmailAddress; quoteVm.Quote = Math.Round(insuree.Quote, 2); quoteVms.Add(quoteVm); } return(View(quoteVms)); } }
// GET: Admin public ActionResult Index() { using (InsuranceEntities db = new InsuranceEntities()) { var quotes = db.Quotes; var quoteVms = new List <QuoteVm>(); foreach (var quote in quotes) { var quoteVm = new QuoteVm(); quoteVm.FirstName = quote.FirstName; quoteVm.LastName = quote.LastName; quoteVm.EmailAddress = quote.EmailAddress; quoteVm.Price = Convert.ToInt32(quote.Price); quoteVms.Add(quoteVm); } return(View(quoteVms)); } }
// GET: Admin public ActionResult Index() { using (var db = new CarInsuranceEntities1()) { var quotes = db.InsuranceQuotes; var quoteVms = new List <QuoteVm>(); foreach (var quote in quotes) { var quoteVm = new QuoteVm(); quoteVm.FirstName = quote.FirstName; quoteVm.LastName = quote.LastName; quoteVm.EmailAddress = quote.EmailAddress; quoteVm.QuoteAmount = (decimal)quote.Quote; quoteVms.Add(quoteVm); } return(View(quoteVms)); } }
// GET: Admin public ActionResult Index() { using (InsuranceQuotesEntities db = new InsuranceQuotesEntities()) { List <Quote> quotes = db.Quotes.Where(x => x.Quote1 != null).ToList(); var quoteVms = new List <QuoteVm>(); foreach (var quote in quotes) { var quoteVm = new QuoteVm(); quoteVm.FirstName = quote.FirstName; quoteVm.LastName = quote.LastName; quoteVm.EmailAddress = quote.EmailAddress; quoteVm.Quote = Convert.ToString(quote.Quote1); quoteVms.Add(quoteVm); } return(View(quoteVms)); } }
// GET: Admin public ActionResult Index() { using (ACMECarInsuranceEntities db = new ACMECarInsuranceEntities()) { var quotes = db.ACMEQuotes.ToList(); var quotesVms = new List <QuoteVm>(); foreach (var quote in quotes) { var quoteVm = new QuoteVm(); quoteVm.FirstName = quote.FirstName; quoteVm.LastName = quote.LastName; quoteVm.EmailAddress = quote.EmailAddress; quoteVm.QuoteTotal = Convert.ToDecimal(quote.QuoteTotal); quotesVms.Add(quoteVm); } return(View(quotesVms)); } }
// GET: Admin public ActionResult Index() { using (CarQuoteEntities db = new CarQuoteEntities()) { var quotes = (from c in db.Quotes select c).ToList(); var quoteVms = new List <QuoteVm>(); foreach (var quote in quotes) { var quoteVm = new QuoteVm(); quoteVm.Id = quote.Id; quoteVm.FirstName = quote.FirstName; quoteVm.LastName = quote.LastName; quoteVm.EmailAddress = quote.EmailAddress; quoteVms.Add(quoteVm); } return(View(quoteVms)); } }
public ActionResult Index() { using (InsuranceDetailsEntities db = new InsuranceDetailsEntities()) { var quotes = db.UserDetails.Where(x => x.Id > 0).ToList(); var quoteVms = new List <QuoteVm>(); foreach (var x in quotes) { var quoteVm = new QuoteVm(); quoteVm.Id = x.Id; quoteVm.FirstName = x.FirstName; quoteVm.LastName = x.LastName; quoteVm.EmailAddress = x.EmailAddress; quoteVms.Add(quoteVm); } return(View(quoteVms)); } }
// GET: Admin public ActionResult Index() { using (QuotesEntities db = new QuotesEntities()) {; var quotes = db.Quotes; var quoteVms = new List <QuoteVm>(); foreach (var Quotes in quoteVms) { //var is named "Quotes" rather than "Quote" because the title //of the edmx table couldn't be the same as the parameter "Quote". var quoteVm = new QuoteVm(); quoteVm.Id = Quotes.Id; quoteVm.Quote = Convert.ToDouble(Quotes.Quote); quoteVm.FirstName = Quotes.FirstName; quoteVm.LastName = Quotes.LastName; quoteVm.EmailAddress = Quotes.EmailAddress; quoteVms.Add(quoteVm); } return(View(quoteVms)); } }
public ActionResult Index() { using (InsuranceEntities2 db = new InsuranceEntities2()) { var quotes = db.Quotes; var quoteVms = new List <QuoteVm>(); foreach (var vquote in quotes) { var quoteVm = new QuoteVm(); quoteVm.Id = vquote.Id; quoteVm.Total = vquote.Total; quoteVm.FirstName = vquote.FirstName; quoteVm.LastName = vquote.LastName; quoteVm.EmailAddress = vquote.EmailAddress; quoteVms.Add(quoteVm); } return(View(quoteVms)); } }
// GET: Admin public ActionResult Index() { using (InsuranceEntities db = new InsuranceEntities()) { var quotes = (from c in db.Quotes where c.Removed == null select c).ToList(); var quoteVms = new List <QuoteVm>(); foreach (var quote in quotes) { var quoteVm = new QuoteVm(); quoteVm.Id = quote.Id; quoteVm.FirstName = quote.FirstName; quoteVm.LastName = quote.LastName; quoteVm.EmailAddress = quote.EmailAddress; quoteVm.CustomerQuote = quote.CustomerQuote; quoteVms.Add(quoteVm); } return(View(quoteVms)); } }
// GET: Admin public ActionResult Index() { using (CarInsuranceEntities db = new CarInsuranceEntities()) { var quotes = db.Quotes; // this var represents all rows in the Quotes table var quoteVms = new List <QuoteVm>(); foreach (var quote in quotes) { var quoteVm = new QuoteVm { // map the applicable columns from the Model to our ViewModel FirstName = quote.FirstName, LastName = quote.LastName, EmailAddress = quote.EmailAddress, MonthlyPremium = (float)quote.MonthlyPremium }; quoteVms.Add(quoteVm); // add the row to our list of quotes } return(View(quoteVms)); // and display to our view } }
// GET: Admin public ActionResult Index() { using (CarInsuranceEntities1 db = new CarInsuranceEntities1()) { var quotes = db.CarInsurances.ToList(); var quotelist = new List <QuoteVm>(); foreach (var x in quotes) { var carquote = new QuoteVm(); carquote.Id = x.Id; carquote.FirstName = x.FirstName; carquote.LastName = x.LastName; carquote.EmailAddress = x.EmailAddress; carquote.FullQuote = x.FullQuote; carquote.LiabilityQuote = x.LiabilityQuote; quotelist.Add(carquote); } return(View(quotelist)); } }
public ActionResult Quote() { using (BEInsuranceEntities db = new BEInsuranceEntities()) { var AllCustomers = db.Customers; //var CustomerList = new List<Customer>(); var quoteVms = new List <QuoteVm>(); foreach (var customer in AllCustomers) { var quoteVm = new QuoteVm(); quoteVm.Id = customer.Id; quoteVm.FirstName = customer.FirstName; quoteVm.LastName = customer.LastName; quoteVm.Quote = (double)customer.Quote; if (quoteVm.Id == AllCustomers.Count()) { quoteVms.Add(quoteVm); } } return(View(quoteVms)); } }
// GET: Admin public ActionResult Index() { using (QuoteDBEntities db = new QuoteDBEntities()) { var quotes = db.Quotes.ToList(); var quoteVms = new List <QuoteVm>(); foreach (var quote in quotes) { var quoteVm = new QuoteVm(); quoteVm.Id = quote.Id; quoteVm.firstName = quote.FirstName; quoteVm.lastName = quote.LastName; quoteVm.emailAddress = quote.EmailAddress; quoteVm.quotedCost = Convert.ToDouble(quote.QuotedCost); quoteVms.Add(quoteVm); } // return(View(quoteVms)); } }
public ActionResult Quote(string firstName, string lastName, string emailAddress, DateTime dateOfBirth, int modelYear, string makeOfCar, string modelOfCar, string dui, int numSpeedingTickets, string coverageType) { // Start with base of $50/month double insQuote = 50.0; // calculate age of customer DateTime now = DateTime.Now; int customerAge = now.Year - dateOfBirth.Year; if (dateOfBirth.DayOfYear > now.DayOfYear) { customerAge -= 1; } // Increase quote per age risk categories if (customerAge < 18) { insQuote += 100; } else if (customerAge < 25) { insQuote += 50; } else if (customerAge > 100) { insQuote += 25; } // Increase quote per age of car if (modelYear < 2000) { insQuote += 25; } else if (modelYear > 2015) { insQuote += 25; } // if it's a Porche increase quote, and if it's a Porche 911 Carrera, increase some more if (new List <string> { "porche", "porsh", "porshe", "porch", "porsha" }.Contains(makeOfCar.ToLower())) { insQuote += 25; if (new List <string> { "911 carrera", "911 carerra", "911 carera", "911 carrerra" }.Contains(modelOfCar.ToLower())) { insQuote += 25; } } // Add 10 for every speeding ticket insQuote += (numSpeedingTickets * 10); // If DUI, add 25% to total if (dui == "Yes") { insQuote *= 1.25; } // If full coverage.... if (coverageType == "Full") { insQuote *= 1.5; } //round the quote to 2 decimal places before it gets used insQuote = Math.Round(insQuote, 2); // Save the data to the database using (CarInsuranceEntities db = new CarInsuranceEntities()) { var quote = new Quote { FirstName = firstName, LastName = lastName, EmailAddress = emailAddress, DateOfBirth = dateOfBirth, ModelOfCar = modelOfCar, MakeOfCar = makeOfCar, ModelYear = modelYear, DUI = (dui == "Yes"), // The form strictly controls what is passed in dui NumSpeedingTickets = numSpeedingTickets, CoverageType = coverageType, MonthlyPremium = insQuote }; db.Quotes.Add(quote); db.SaveChanges(); } // Using a ViewModel, prepare the final quote for display to customer. Capture only relavant info var finalQuote = new QuoteVm() { FirstName = firstName, MonthlyPremium = (float)insQuote }; // pass the quote for display to the customer return(View(finalQuote)); // goes to the Quote.cshtml view }
public ActionResult Quote(string FirstName, string LastName, string EmailAddress, DateTime DoB, int CarYear, string CarMake, string CarModel, bool DUI, int Ticket, string Coverage) { //Quote calculations QuoteVm quote = new QuoteVm(); quote.Quote = 50d; int age = Convert.ToInt32(DateTime.Today.Year - DoB.Year); if (age < 25) { quote.Quote += 25d; } if (age < 100) { quote.Quote += 100d; } if (age > 100) { quote.Quote += 25d; } if (CarYear < 2000) { quote.Quote += 25d; } if (CarYear > 2015) { quote.Quote += 25d; } if (CarMake == "Porsche") { quote.Quote += 25d; } if (CarModel == "911 Carrera") { quote.Quote += 25d; } for (int i = 0; i < Ticket; i++) { quote.Quote += 10d; } if (DUI) { double percent = quote.Quote * .25d; quote.Quote += percent; } Coverage = Coverage.ToLower(); if (Coverage == "coverage") { double percent = quote.Quote * .50d; quote.Quote += percent; } //Database Update using (InsuranceEntities database = new InsuranceEntities()) { var customer = new Customer(); customer.Quote = Convert.ToDecimal(quote.Quote); customer.FirstName = FirstName; customer.LastName = LastName; customer.EmailAddress = EmailAddress; customer.DoB = DoB; customer.CarYear = CarYear; customer.CarMake = CarMake; customer.CarModel = CarModel; customer.DUI = DUI; customer.Ticket = Ticket; customer.Coverage = Coverage; database.Customers.Add(customer); database.SaveChanges(); } return(View("Success")); }
public ActionResult Quote(DateTime DateOfBirth, int CarYear, string CarMake, string CarModel, int SpeedingTickets, string FirstName, string LastName, string Email, bool DUI = false, bool FullCoverage = false) { decimal Quote = 50.0m; int dob = DateOfBirth.Year; int thisYear = DateTime.Now.Year; int birthYear = thisYear - dob; int age = thisYear = birthYear; if (age < 18) { Quote += 100m; } else if (age > 18 && age < 25) { Quote += 25m; } else if (age > 100) { Quote += 25m; } if (CarYear < 2000) { Quote += 25m; } else if (CarYear > 2015) { Quote += 25m; } if (CarMake == "Porsche") { Quote += 25m; } if (CarMake == "Porsche" && CarModel == "911 Carrera") { Quote += 25m; } for (int i = 0; i < SpeedingTickets; i++) { Quote += 10m; } if (DUI) { Quote += (Quote * 0.25m); } if (FullCoverage) { Quote += (Quote * 0.50m); } using (InsuranceQuoteEntities db = new InsuranceQuoteEntities()) { var insuranceDb = new QuoteData(); insuranceDb.FirstName = FirstName; insuranceDb.LastName = LastName; insuranceDb.EmailAddress = Email; insuranceDb.DateOfBirth = DateOfBirth; insuranceDb.CarYear = CarYear; insuranceDb.CarMake = CarMake; insuranceDb.CarModel = CarModel; insuranceDb.SpeedingTickets = SpeedingTickets; insuranceDb.DUI = DUI; insuranceDb.FullCoverage = FullCoverage; insuranceDb.Quote = Quote; db.QuoteDatas.Add(insuranceDb); db.SaveChanges(); } QuoteVm quoteVm = new QuoteVm(); quoteVm.FirstName = FirstName; quoteVm.LastName = LastName; quoteVm.Email = Email; quoteVm.Quote = Math.Round(Quote, 2); return(View(quoteVm)); }
public ActionResult Quote() { v_UserQuotes userQuote = new v_UserQuotes(); userQuote.FirstName = Request["FirstName"]; userQuote.LastName = Request["LastName"]; userQuote.Email = Request["EmailAddress"]; var Make = Request["Make"]; var Model = Request["Model"]; userQuote.Year = int.Parse(Request["CarYear"].ToString()); userQuote.SpeedingTickets = int.Parse(Request["SpeedTickets"].ToString()); userQuote.DOB = DateTime.Parse(Request["DOB"].ToString()); userQuote.DUI = string.IsNullOrEmpty(Request["DUI"]) ? false : true; userQuote.IsFullCoverage = string.IsNullOrEmpty(Request["IsFullCoverage"]) ? false : true; if (string.IsNullOrEmpty(userQuote.FirstName) || string.IsNullOrEmpty(userQuote.LastName) || string.IsNullOrEmpty(userQuote.Email) || string.IsNullOrEmpty(Make) || string.IsNullOrEmpty(Model) ) { return(View("~/Views/Shared/Error.cshtml")); } else { List <v_CarMakeModelMasterList> LookupCars = GetVehicleMasterList(); QuoteVm quoteVm = new QuoteVm(); v_CarMakeModelMasterList Temp = LookupCars.FirstOrDefault(c => c.Manufacturer == Make && c.Name == Model); userQuote.CarMakeModelId = (int)Temp.Id; quoteVm.FirstName = userQuote.FirstName; quoteVm.LastName = userQuote.LastName; quoteVm.Premium = 0.00m; // Calculate premium userQuote.Premium = 50.0m; userQuote.Premium += ((DateTime.Now.Year - userQuote.DOB.Year) < 18) ? 100.0m : 0; if ((((DateTime.Now.Year - userQuote.DOB.Year) >= 18) && ((DateTime.Now.Year - userQuote.DOB.Year) < 25)) || ((DateTime.Now.Year - userQuote.DOB.Year) > 25)) { userQuote.Premium += 25.0m; } if (userQuote.Year < 2000 || userQuote.Year > 2015) { userQuote.Premium += 25.0m; } userQuote.Premium += (Make == "Porsche") ? 25.0m : 0; userQuote.Premium += (Model == "911 Carrera") ? 25.0m : 0; userQuote.Premium += userQuote.SpeedingTickets * 10.0m; userQuote.Premium += (userQuote.DUI) ? userQuote.Premium * 1.25m : 0; userQuote.Premium += (userQuote.IsFullCoverage) ? userQuote.Premium * 1.50m : 0; quoteVm.Premium = (decimal)userQuote.Premium; using (SqlConnection connection = new SqlConnection(connectionString)) { SqlCommand command = new SqlCommand(@"PROC_Save_User_Info_for_Quote", connection); command.CommandType = System.Data.CommandType.StoredProcedure; command.Parameters.Clear(); command.Parameters.Add("FirstName", SqlDbType.VarChar); command.Parameters.Add("LastName", SqlDbType.VarChar); command.Parameters.Add("Email", SqlDbType.VarChar); command.Parameters.Add("DOB", SqlDbType.DateTime); command.Parameters.Add("CarMakeModelId", SqlDbType.Int); command.Parameters.Add("Year", SqlDbType.Int); command.Parameters.Add("SpeedingTickets", SqlDbType.Int); command.Parameters.Add("IsFullCoverage", SqlDbType.Bit); command.Parameters.Add("DUI", SqlDbType.Bit); command.Parameters.Add("Premium", SqlDbType.Decimal); command.Parameters["FirstName"].Value = userQuote.FirstName; command.Parameters["LastName"].Value = userQuote.LastName; command.Parameters["Email"].Value = userQuote.Email; command.Parameters["DOB"].Value = userQuote.DOB; command.Parameters["CarMakeModelId"].Value = userQuote.CarMakeModelId; command.Parameters["Year"].Value = userQuote.Year; command.Parameters["SpeedingTickets"].Value = userQuote.SpeedingTickets; command.Parameters["IsFullCoverage"].Value = userQuote.IsFullCoverage; command.Parameters["DUI"].Value = userQuote.DUI; command.Parameters["Premium"].Value = (decimal)userQuote.Premium; connection.Open(); command.ExecuteNonQuery(); connection.Close(); } return(View("Success", quoteVm)); } }