// 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 (CarInsuranceEntities1 db = new CarInsuranceEntities1()) { var customerList = db.CustomerQuotes; var customers = new List <CustomerQuote>(); foreach (var customer in customerList) { var customersQuote = new CustomerQuote(); customersQuote.FirstName = customer.FirstName; customersQuote.LastName = customer.LastName; customersQuote.EmailAddress = customer.EmailAddress; customersQuote.QuoteEstimate = customer.QuoteEstimate; customers.Add(customersQuote); } return(View(customers)); } }
// 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 GetQuote(string firstName, string lastName, string emailAddress, int age, string dui, int carYear, string carMake, string carModel, int tickets, string coverage) { int runningQuote = 50; if (age < 18) { runningQuote = (runningQuote + 100); } else if (age < 25 || age > 100) { runningQuote = (runningQuote + 25); } if (carYear < 2000 || carYear > 2015) { runningQuote = runningQuote + 25; } if (carMake == "Porche" || carMake == "porche") { runningQuote = runningQuote + 25; } if (carMake == "Porche" || carMake == "porche" && carModel == "911 Carrera" || carModel == "911 carrera") { runningQuote = runningQuote + 25; } if (tickets > 0) { runningQuote = runningQuote + (tickets * 10); } if (dui == "yes" || dui == "ya" || dui == "yeah") { runningQuote = runningQuote + (runningQuote * (1 / 4)); } if (coverage == "full") { runningQuote = runningQuote + (runningQuote * (1 / 2)); } ViewBag.text = coverage; using (CarInsuranceEntities1 db = new CarInsuranceEntities1()) { var customer = new CustomerQuote(); customer.FirstName = firstName; customer.LastName = lastName; customer.EmailAddress = emailAddress; customer.QuoteEstimate = runningQuote; db.CustomerQuotes.Add(customer); db.SaveChanges(); } return(View("Quoted", runningQuote)); }
public ActionResult SendForm(string firstName, string lastName, string emailAddress, DateTime dateOfBirth, int carYear, string carMake, string carModel, bool dui, int speedTickets, string coverage) { if (string.IsNullOrEmpty(firstName) || string.IsNullOrEmpty(lastName) || string.IsNullOrEmpty(emailAddress) || dateOfBirth == null || carYear == 0 || string.IsNullOrEmpty(carMake) || string.IsNullOrEmpty(carModel) || string.IsNullOrEmpty(coverage)) { return(View("~/Views/Shared/Error.cshtml")); } decimal quoteAmount = 50; using (var db = new CarInsuranceEntities1()) { var quote = new InsuranceQuote(); if (DateTime.Now - dateOfBirth < TimeSpan.FromDays(365 * 25))// if user is under 25 { quoteAmount += 25; } if (DateTime.Now - dateOfBirth < TimeSpan.FromDays(365 * 18))// if user is under 18 { quoteAmount += 100; } else if (DateTime.Now - dateOfBirth > TimeSpan.FromDays(365 * 100))// if user is over 100 { quoteAmount += 25; } if (carYear < 2000) { quoteAmount += 25; } else if (carYear > 2015) { quoteAmount += 25; } if (carMake.ToLower().Contains("porsche")) { quoteAmount += 25; if (carModel.ToLower().Contains("911 carrera")) { quoteAmount += 25; } } quoteAmount += speedTickets * 10; if (dui) { quoteAmount *= (decimal)1.25; } bool fullCoverage = (coverage == "Full"); if (fullCoverage) { quoteAmount *= (decimal)1.5; } quote.FirstName = firstName; quote.LastName = lastName; quote.EmailAddress = emailAddress; quote.DateOfBirth = dateOfBirth; string CarDate = string.Format("01-01-" + carYear); quote.CarYear = DateTime.Parse(CarDate); quote.CarMake = carMake; quote.CarModel = carModel; quote.Dui = dui; quote.SpeedTickets = speedTickets; quote.FullCoverage = fullCoverage; quote.Quote = quoteAmount; db.InsuranceQuotes.Add(quote); db.SaveChanges(); } return(View("Quote", quoteAmount)); }
public ActionResult Index(string firstName, string lastName, string emailAddress, DateTime DOB, int CarYear, string CarMake, string CarModel, string DUI, string Tickets, string coverage) { flag = true; ViewBag.flagvalue = flag; double quote = 50; int year = DateTime.Now.Year; int useryear = DOB.Year; int age = year - useryear; if (age < 25 && age >= 18 || age > 100) { quote += 25; } else if (age < 18) { quote += 100; } if (CarYear < 2000) { quote += 25; } else if (CarYear > 2015) { quote += 25; } string carmodel = CarModel.ToLower(); string carmake = CarMake.ToLower(); if (carmake == "porsche") { quote += 25; if (carmodel == "911 carrera") { quote += 25; } } quote += Convert.ToInt32(Tickets) * 10; string dui = DUI.ToLower(); if (dui == "yes") { quote = quote * 1.25; } double fullquote = quote * 1.5; double liabilityquote = quote; string Coverage = Request.Form["coverage"]; if (Coverage == "full") { quote = fullquote; } else { quote = liabilityquote; } ViewBag.quote = quote; using (CarInsuranceEntities1 db = new CarInsuranceEntities1()) { var carinsurance = new CarInsurance(); carinsurance.FirstName = firstName; carinsurance.LastName = lastName; carinsurance.EmailAddress = emailAddress; carinsurance.DOB = DOB.ToString(); carinsurance.CarYear = CarYear.ToString(); carinsurance.CarMake = CarMake; carinsurance.CarModel = CarModel; carinsurance.DUI = DUI; carinsurance.Ticket = Tickets; carinsurance.Coverage = Coverage; carinsurance.FullQuote = fullquote.ToString(); carinsurance.LiabilityQuote = liabilityquote.ToString(); db.CarInsurances.Add(carinsurance); db.SaveChanges(); } return(View()); }