// GET: Admin public ActionResult Index() { using (CarInsuranceQuotesEntities db = new CarInsuranceQuotesEntities()) { var dbQuotes = db.Quotes; var quoteList = new List <QuotePar>(); // foreach (var qq in dbQuotes) { var quoteVar = new QuotePar(); quoteVar.firstName = qq.FirstName; quoteVar.lastName = qq.LastName; quoteVar.dateBirth = Convert.ToDateTime(qq.DateBirth); quoteVar.carYear = Convert.ToInt32(qq.CarYear); quoteVar.carMake = qq.CarMake; quoteVar.carModel = qq.CarModel; if (Convert.ToBoolean(qq.DUI)) { quoteVar.diu = "Y"; } else { quoteVar.diu = "N"; } quoteVar.speedTickets = Convert.ToInt32(qq.SpeedTickets); if (Convert.ToBoolean(qq.FullCoverage)) { quoteVar.cover = "1"; } else { quoteVar.cover = "2"; } quoteVar.emailAddress = qq.EmailAddress; quoteVar.quoteDate = Convert.ToDateTime(qq.QuoteDate); quoteVar.totalQuote = Convert.ToDecimal(qq.QuoteAmount); // quoteList.Add(quoteVar); // } return(View(quoteList)); } }
public ActionResult QuoteCal(QuotePar quote) { decimal qTotal = 50; double age = 0; // TimeSpan aget = DateTime.Now - quote.dateBirth; age = aget.TotalDays / 365; // if (age < 18) { qTotal += 100; } else if (age < 25 || age > 100) { qTotal += 25; } // if (quote.carYear < 2000) { qTotal += 25; } else if (quote.carYear > 2015) { qTotal += 25; } // if (quote.carMake.ToLower() == "porsche") { qTotal += 25; if (quote.carModel.ToLower() == "carrera") { qTotal += 25; } } // qTotal = qTotal + (quote.speedTickets * 10); // if (quote.diu == "Y") { qTotal = Percent(qTotal, 25); } // if (quote.cover == "1") { qTotal = Percent(qTotal, 50); } // quote.totalQuote = qTotal; // using (CarInsuranceQuotesEntities db = new CarInsuranceQuotesEntities()) { var dbQuote = new Quote(); dbQuote.LastName = quote.lastName; dbQuote.FirstName = quote.firstName; dbQuote.EmailAddress = quote.emailAddress; dbQuote.DateBirth = quote.dateBirth; dbQuote.CarYear = quote.carYear; dbQuote.CarModel = quote.carModel; dbQuote.CarMake = quote.carMake; if (quote.diu == "Y") { dbQuote.DUI = true; } else { dbQuote.DUI = false; } dbQuote.SpeedTickets = quote.speedTickets; if (quote.cover == "1") { dbQuote.FullCoverage = true; } else { dbQuote.FullCoverage = false; } dbQuote.QuoteDate = DateTime.Now; dbQuote.QuoteAmount = qTotal; // db.Quotes.Add(dbQuote); db.SaveChanges(); // } // return(View(quote)); }