Example #1
0
        public ActionResult GetQuote(string firstName, string lastName, string emailAddress, string dateOfBirth, string carYear, string carMake, string carModel, string dui, string tickets, string fullLiability)
        {
            if (string.IsNullOrEmpty(firstName) || string.IsNullOrEmpty(lastName) || string.IsNullOrEmpty(emailAddress) || string.IsNullOrEmpty(dateOfBirth) || string.IsNullOrEmpty(carYear) || string.IsNullOrEmpty(carMake) || string.IsNullOrEmpty(carModel) || string.IsNullOrEmpty(dui) || string.IsNullOrEmpty(tickets) || string.IsNullOrEmpty(fullLiability))
            {
                return(View("~/Views/Shared/Error.cshtml"));
            }
            else
            {
                using (CarInsuranceQuotesEntities db = new CarInsuranceQuotesEntities())
                {
                    var getQuote = new Customer();
                    getQuote.FirstName     = firstName;
                    getQuote.LastName      = lastName;
                    getQuote.EmailAddress  = emailAddress;
                    getQuote.DateOfBirth   = dateOfBirth;
                    getQuote.CarYear       = carYear;
                    getQuote.CarMake       = carMake;
                    getQuote.CarModel      = carModel;
                    getQuote.DUI           = dui;
                    getQuote.Tickets       = tickets;
                    getQuote.FullLiability = fullLiability;

                    db.Customers.Add(getQuote);
                    db.SaveChanges();
                }
            }

            return(View("Success"));
        }
Example #2
0
        public ActionResult GetQuote(string firstName, string lastName, string emailAddress,
                                     DateTime dateOfBirth, string carYear, string carMake,
                                     string carModel, string duiString, int tickets, string coverageLevel)
        {
            bool dui = false;

            if (duiString == "true")
            {
                dui = true;
            }
            var quote = new Quote()
            {
                FirstName     = firstName,
                LastName      = lastName,
                EmailAddress  = emailAddress,
                BirthDate     = dateOfBirth,
                CarMake       = carMake,
                CarModel      = carModel,
                Dui           = dui,
                Tickets       = tickets,
                CoverageLevel = coverageLevel
            };
            bool intCheck = Int32.TryParse(carYear, out int carYearInt);

            if (intCheck)
            {
                quote.CarYear = carYearInt;
            }
            else
            {
                quote.CarYear = 0;
            }
            bool?inputValid = AllInputValid(quote);

            if (inputValid == false)
            {
                ViewBag.Message("Make sure all fields are filled out.  Please try again!");
                return(View("~/Views/Shared/Error.cshtml"));
            }
            else if (inputValid == null)
            {
                ViewBag.Message("The model year you entered was not in a valid format.  Please enter digits in the format yyyy.");
                return(View("~/Views/Shared/Error.cshtml"));
            }
            else
            {
                using (CarInsuranceQuotesEntities db = new CarInsuranceQuotesEntities())
                {
                    GenerateQuote(quote);
                    db.Quotes.Add(quote);
                    db.SaveChanges();
                }
                //string returnView = (@"Home/Quote/");  //Will this work?!
                ViewBag.quoteValue = quote.QuoteValue;
                ViewBag.firstName  = quote.FirstName;
                return(View("Quote"));
            }
        }
 public ActionResult Unsubscribe(int quoteID)
 {
     using (CarInsuranceQuotesEntities db = new CarInsuranceQuotesEntities())
     {
         var quote = db.Quotes.Find(quoteID);
         quote.Removed = DateTime.Now;
         db.SaveChanges();
     }
     return(RedirectToAction("Index"));
 }
        public ActionResult Quote(string firstName, string lastName, string emailAddress, DateTime?dateOfBirth, int?carYear,
                                  string carMake, string carModel, int?speedingTickets, bool?dUI = false,
                                  bool?fullCoverage = false, bool?liability = false, decimal?quoteTotal = 50.00m)
        {
            if (string.IsNullOrEmpty(firstName) || string.IsNullOrEmpty(lastName) || string.IsNullOrEmpty(emailAddress) ||
                dateOfBirth == null || carYear == null || string.IsNullOrEmpty(carMake) || string.IsNullOrEmpty(carModel))
            {
                return(View("~/Views/Shared/Error.cshtml"));
            }
            else
            {
                DateTime dob       = Convert.ToDateTime(dateOfBirth);
                var      driverAge = DateTime.Now.Year - dob.Year;

                if (driverAge < 25 || driverAge > 100)
                {
                    quoteTotal += 25.00m;
                }
                if (driverAge < 18)
                {
                    quoteTotal += 100.00m;
                }
                if (carYear < 2000 || carYear > 2015)
                {
                    quoteTotal += 25.00m;
                }
                if (carMake == "Porsche")
                {
                    quoteTotal += 25.00m;
                }
                if (carModel == "911 Carrera")
                {
                    quoteTotal += 25.00m;
                }
                if (speedingTickets > 0)
                {
                    quoteTotal += speedingTickets * 10.00m;
                }
                if (dUI == true)
                {
                    quoteTotal *= 1.25m;
                }
                if (fullCoverage == true)
                {
                    quoteTotal *= 1.5m;
                }

                using (CarInsuranceQuotesEntities db = new CarInsuranceQuotesEntities())
                {
                    var quote = new Quote
                    {
                        FirstName       = firstName,
                        LastName        = lastName,
                        EmailAddress    = emailAddress,
                        DateOfBirth     = dateOfBirth,
                        CarYear         = carYear,
                        CarMake         = carMake,
                        CarModel        = carModel,
                        DUI             = dUI,
                        SpeedingTickets = speedingTickets,
                        FullCoverage    = fullCoverage,
                        Liability       = liability,
                        QuoteTotal      = quoteTotal
                    };
                    TempData["QT"] = quote;
                    db.Quotes.Add(quote);
                    db.SaveChanges();
                }
                return(Redirect("/Home/QuoteDetails"));
            }
        }
Example #5
0
        public ActionResult InsuranceQuoteCustomer(string firstName, string lastName, string emailAddress, DateTime dateOfBirth, int?carYear, string carMake,
                                                   string carModel, bool everDUI, int?speedingTickets, string fullCoverageOrLiability, int finalQuote = 0)
        {
            if (string.IsNullOrEmpty(firstName) || string.IsNullOrEmpty(lastName) || string.IsNullOrEmpty(emailAddress) ||
                dateOfBirth == null || (carYear ?? 0) == 0 || string.IsNullOrEmpty(carMake) || string.IsNullOrEmpty(carModel) ||
                everDUI.ToString() == null || string.IsNullOrEmpty(fullCoverageOrLiability) || speedingTickets == null)
            {
                return(View("~/Views/Shared/Error.cshtml"));
            }
            else
            {
                using (CarInsuranceQuotesEntities carQuoteDb = new CarInsuranceQuotesEntities())
                {
                    var carQuote = new InsuranceQuoteCustomer();
                    carQuote.FirstName               = firstName;
                    carQuote.LastName                = lastName;
                    carQuote.EmailAddress            = emailAddress;
                    carQuote.DateOfBirth             = dateOfBirth;
                    carQuote.CarYear                 = carYear;
                    carQuote.CarMake                 = carMake;
                    carQuote.CarModel                = carModel;
                    carQuote.EverDUI                 = everDUI;
                    carQuote.SpeedingTickets         = speedingTickets;
                    carQuote.FullCoverageOrLiability = fullCoverageOrLiability;
                    carQuote.FinalQuote              = finalQuote;

                    decimal baseQuote = 50m;

                    int speedingPenalty = (int)speedingTickets * 10;
                    baseQuote += speedingPenalty;

                    var today = DateTime.Today;
                    var age   = today.Year - dateOfBirth.Year;

                    string coverage = fullCoverageOrLiability.ToLower();
                    string make     = carMake.ToLower();
                    string model    = carModel.ToLower();

                    if (age < 25 || age > 100 || carYear < 2000 || carYear >= 2015)
                    {
                        baseQuote += 25;
                    }
                    if (age < 18)
                    {
                        baseQuote += 100;
                    }
                    if (make == "porsche")
                    {
                        baseQuote += 25;
                    }
                    if (make == "Porsche" && model == "911 Carrera")
                    {
                        baseQuote += 25;
                    }
                    if (everDUI == true)
                    {
                        baseQuote *= 1.25m;
                    }
                    if (fullCoverageOrLiability == "full" || fullCoverageOrLiability == "full coverage")
                    {
                        baseQuote *= 1.5m;
                    }
                    carQuote.FinalQuote = (int)baseQuote;
                    carQuoteDb.InsuranceQuoteCustomers.Add(carQuote);
                    CarInsuranceVm CarVm = new CarInsuranceVm();
                    CarVm.FinalQuote = (int)baseQuote;
                    carQuoteDb.SaveChanges();
                    return(View("SuccessQuote"));
                }
            }
        }
Example #6
0
        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));
        }
        public ActionResult InsuranceQuote(string firstName, string lastName, string dateOfBirth, string emailAddress, string carMake, string carModel, string carYear, string coverage, string dui, string speedingTickets)
        {
            decimal baseQuote = 50m;

            DateTime newBirthDay = Convert.ToDateTime(dateOfBirth);
            DateTime todayDate   = DateTime.Today;
            int      age         = todayDate.Year - newBirthDay.Year;

            if (newBirthDay > todayDate.AddYears(-age))
            {
                age--;
            }
            if (age < 25)
            {
                baseQuote += 25;
            }
            if (age < 18)
            {
                baseQuote += 100;
            }
            if (age > 100)
            {
                baseQuote += 25;
            }

            int newCarYear = Convert.ToInt32(carYear);

            if (newCarYear < 2000)
            {
                baseQuote += 25;
            }
            if (newCarYear > 2015)
            {
                baseQuote += 25;
            }

            if (carMake == "Porsche")
            {
                baseQuote += 25;
            }
            if (carModel == "911 Carrera")
            {
                baseQuote += 25;
            }

            int tickets = Convert.ToInt32(speedingTickets);

            for (int i = 0; i < tickets; i++)
            {
                baseQuote += 10;
            }

            if (dui == "Yes")
            {
                baseQuote += (baseQuote * .25m);
            }

            if (coverage == "Full Coverage")
            {
                baseQuote += (baseQuote * .5m);
            }

            using (CarInsuranceQuotesEntities db = new CarInsuranceQuotesEntities())
            {
                var quote = new CarInsuraceQuote();
                quote.FirstName       = firstName;
                quote.LastName        = lastName;
                quote.DateOfBirth     = dateOfBirth;
                quote.EmailAddress    = emailAddress;
                quote.CarMake         = carMake;
                quote.CarModel        = carModel;
                quote.CarYear         = Convert.ToInt32(carYear);
                quote.Coverage        = coverage;
                quote.DUI             = dui;
                quote.SpeedingTickets = Convert.ToInt32(speedingTickets);
                quote.VehicleQuote    = Convert.ToInt32(baseQuote);

                db.CarInsuraceQuotes.Add(quote);
                db.SaveChanges();
            }

            return(View("Success"));
        }