public ActionResult Admin() { using (QuoteApplication db = new QuoteApplication()) { var quotes = db.Quotes; var filters = new List <Filter>(); foreach (var quote in quotes) { var filter = new Filter(); filter.FirstName = quote.FirstName; filter.LastName = quote.LastName; filter.EmailAddress = quote.EmailAddress; filters.Add(filter); } return(View(filters)); } }
public ActionResult Apply(string firstName, string lastName, string emailAddress, string dateOfBirth, int year, string make, string model, string DUI, int speedingTicket, string coverage) { double totalAmount; if (string.IsNullOrEmpty(firstName) || string.IsNullOrEmpty(lastName) || string.IsNullOrEmpty(emailAddress) || string.IsNullOrEmpty(dateOfBirth) || string.IsNullOrEmpty(year.ToString()) || string.IsNullOrEmpty(make) || string.IsNullOrEmpty(model) || string.IsNullOrEmpty(DUI) || string.IsNullOrEmpty(speedingTicket.ToString()) || string.IsNullOrEmpty(coverage)) { return(View("~/Views/Shared/Error.cshtml")); } else { totalAmount = Total(dateOfBirth, year, make, model, speedingTicket, DUI, coverage); using (QuoteApplication db = new QuoteApplication()) { var applicant = new Quote(); applicant.FirstName = firstName; applicant.LastName = lastName; applicant.EmailAddress = emailAddress; applicant.DateOfBirth = dateOfBirth; applicant.CarYear = year; applicant.CarMake = make; applicant.CarModel = model; applicant.DUI = DUI; applicant.SpeedingTicket = speedingTicket; applicant.Coverage = coverage; applicant.Amount = totalAmount; db.Quotes.Add(applicant); db.SaveChanges(); } return(View("Success")); } }