public ActionResult CustomerInfo(string firstName, string lastName, string emailAddress, DateTime dateOfBirth, DateTime carYear, string carMake, string carModel, string speedingTickets, string fullCoverage, string dui, double quote = 0) { if (string.IsNullOrEmpty(firstName) || string.IsNullOrEmpty(lastName) || string.IsNullOrEmpty(emailAddress) || string.IsNullOrEmpty(carMake) || string.IsNullOrEmpty(carModel) || string.IsNullOrEmpty(speedingTickets)) { return(View("~/Views/Shared/Error.cshtml")); } else { using (QuoteDbEntities db = new QuoteDbEntities()) { var customer = new CustomerInfo(); customer.FirstName = firstName; customer.LastName = lastName; customer.EmailAddress = emailAddress; customer.DateOfBirth = dateOfBirth; customer.CarYear = carYear; customer.CarMake = carMake; customer.CarModel = carModel; customer.Dui = CheckBool(dui); customer.SpeedingTickets = Convert.ToInt32(speedingTickets); customer.FullCoverage = CheckBool(fullCoverage); quote = CalculateQuote(firstName, lastName, emailAddress, dateOfBirth, carYear, carMake, carModel, CheckBool(dui), speedingTickets, CheckBool(fullCoverage), quote); customer.Quote = quote; db.CustomerInfoes.Add(customer); db.SaveChanges(); ViewBag.Message = quote; } return(View("QuotePage")); } }
public ActionResult QuotePage() { using (QuoteDbEntities db = new QuoteDbEntities()) { var customer = new CustomerInfo(); customer.FirstName = customer.FirstName; customer.LastName = customer.LastName; customer.EmailAddress = customer.EmailAddress; customer.Quote = customer.Quote; return(View(customer)); } }
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)); } }
// GET: Admin public ActionResult Index() { using (QuoteDbEntities db = new QuoteDbEntities()) { //var signups = db.SignUps.Where(x => x.Removed == null).ToList(); var customers = (from c in db.CustomerInfoes where c.Quote != null select c).ToList(); var customerVms = new List <AdminVm>(); foreach (var customer in customers) { var customerVm = new AdminVm(); customerVm.Quote = Convert.ToInt32(customer.Quote); customerVm.FirstName = customer.FirstName; customerVm.LastName = customer.LastName; customerVm.EmailAddress = customer.EmailAddress; customerVms.Add(customerVm); } return(View(customerVms)); } }
public ActionResult Quote(string firstName, string lastName, string emailAddress, DateTime dateOfBirth, int carYear, string carMake, string carModel, string hadDUI, int numberOfTickets, string coverage) { if (string.IsNullOrEmpty(firstName) || string.IsNullOrEmpty(lastName) || string.IsNullOrEmpty(emailAddress) || string.IsNullOrEmpty(carMake) || string.IsNullOrEmpty(carModel) || string.IsNullOrEmpty(hadDUI) || string.IsNullOrEmpty(coverage)) { return(View("~/Views/Shared/Error.cshtml")); } else { var today = DateTime.Today; var age = today.Year - dateOfBirth.Year; decimal total = 50; if (age < 25 && age >= 18) { total += 25; } if (age < 18) { total += 25; } if (age > 100) { total += 25; } if (carYear < 2000) { total += 25; } if (carYear > 2015) { total += 25; } if (carMake == "Porsche") { total += 25; } if (carMake == "Porsche" && carModel == "911 Carrera") { total += 25; } total = total + (10 * numberOfTickets); if (hadDUI == "Yes") { total = (total * 1.25m); } if (coverage == "Full Coverage") { total = (total * 1.5m); } using (QuoteDbEntities db = new QuoteDbEntities()) { var quote = new QuoteTable(); quote.FirstName = firstName; quote.LastName = lastName; quote.EmailAddress = emailAddress; quote.DateOfBirth = dateOfBirth; quote.CarYear = carYear; quote.CarMake = carMake; quote.CarModel = carModel; quote.HadDUI = hadDUI; quote.NumberOfTickets = numberOfTickets; quote.Coverage = coverage; quote.Quote1 = total; db.QuoteTables.Add(quote); db.SaveChanges(); } return(View("Success")); } }
public static double CalculateQuote(string firstName, string lastName, string emailAddress, DateTime dateOfBirth, DateTime carYear, string carMake, string carModel, bool dui, string speedingTickets, bool fullCoverage, double quote) { double runningQuote = 0; using (QuoteDbEntities db = new QuoteDbEntities()) { var customer = new CustomerInfo(); customer.FirstName = firstName; customer.LastName = lastName; customer.EmailAddress = emailAddress; customer.DateOfBirth = dateOfBirth; customer.CarYear = carYear; customer.CarMake = carMake; customer.CarModel = carModel; customer.Dui = dui; customer.SpeedingTickets = Convert.ToInt32(speedingTickets); customer.FullCoverage = fullCoverage; customer.Quote = quote; int tickets = Convert.ToInt32(speedingTickets); runningQuote = 50; DateTime zeroTime = new DateTime(1, 1, 1); DateTime todaysDate = DateTime.Now; TimeSpan span = todaysDate - dateOfBirth; int age = (zeroTime + span).Year - 1; if (age < 25 && age > 17) { runningQuote += 25; } else if (age < 18) { runningQuote += 100; } else if (age > 100) { runningQuote += 25; } int year = carYear.Year; if (year < 2000) { runningQuote += 25; } else if (year > 2005) { ; } { runningQuote += 25; } if (carMake == "Porsche") { runningQuote += 25; } if (carMake == "Porsche" && carModel == "911 Carrera") { runningQuote += 25; } if (tickets > 1) { runningQuote += (10 * tickets); } if (dui) { runningQuote += (runningQuote + (runningQuote * .25)); } if (fullCoverage) { runningQuote += (runningQuote + (runningQuote * .50)); } } return(runningQuote); }