Exemple #1
0
 public ActionResult Edit([Bind(Include = "Id,FirstName,LastName,EmailAddress,DateOfBirth,CarYear,CarMake,CarModel,DUI,SpeedingTickets,CoverageType")] Insuree insuree)
 {
     if (ModelState.IsValid)
     {
         Calculator(insuree, "Save");
         db.Entry(insuree).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(insuree));
 }
Exemple #2
0
        public ActionResult GetQuote(string firstName, string lastName, string emailAddress, DateTime dateOfBirth)
        {
            if (string.IsNullOrEmpty(firstName) || string.IsNullOrEmpty(lastName) || string.IsNullOrEmpty(emailAddress) || dateOfBirth == null)
            {
                return(View("~/Views/Shared/Error.cshtml"));
            }
            else
            {
                using (InsuranceEntities1 db = new InsuranceEntities1())
                {
                    var customer = new tbl_customer();
                    customer.First_Name    = firstName;
                    customer.Last_Name     = lastName;
                    customer.Email_Address = emailAddress;
                    customer.Date_Of_Birth = dateOfBirth;

                    db.tbl_customer.Add(customer);
                    db.SaveChanges();

                    return(View("CarInfo", customer));
                }
            }
        }
Exemple #3
0
        public ActionResult CarInfo(int id, int carYear, string carMake, string carModel, string carDUI, string carCoverage, int carSpeedingTickets = 0)
        {
            if (carYear <= 0 || string.IsNullOrEmpty(carMake) || string.IsNullOrEmpty(carModel) || string.IsNullOrEmpty(carDUI) || carSpeedingTickets < 0 || string.IsNullOrEmpty(carCoverage))
            {
                return(View("~/Views/Shared/Error.cshtml"));
            }
            else
            {
                using (InsuranceEntities1 db = new InsuranceEntities1())
                {
                    //get customer that matches the car info
                    tbl_customer customer = db.tbl_customer.First(x => x.Customer_Id == id);
                    //base total

                    decimal total = 50m;
                    int     age   = DateTime.Now.Year - customer.Date_Of_Birth.Value.Year;

                    //add to monthly payment based on age
                    if (age < 18)
                    {
                        total += 100m;
                    }
                    else if (age < 25)
                    {
                        total += 25m;
                    }
                    else if (age > 100)
                    {
                        total += 25m;
                    }

                    //add to monthly payment based on car year
                    if (carYear < 2000 || carYear > 2015)
                    {
                        total += 25m;
                    }

                    //add based on car make and model note*not checking if user makes a spelling mistake etc
                    if (carMake.ToLower() == "porsche")
                    {
                        total += 25m;
                        if (carModel.ToLower() == "911 Carrera")
                        {
                            total += 25m;
                        }
                    }

                    //add based on speeding tickets
                    if (carSpeedingTickets > 0)
                    {
                        total += carSpeedingTickets * 10;
                    }

                    //add if user has had a DUI
                    if (carDUI.ToLower() == "yes")
                    {
                        total += total * .25m;
                    }

                    //add if coverage is full
                    if (carCoverage.ToLower() == "full")
                    {
                        total += total * .50m;
                    }

                    //update tbl_car table in dB
                    var carInfo = new tbl_car();
                    carInfo.Car_Customer          = id;
                    carInfo.Car_Year              = carYear;
                    carInfo.Car_Make              = carMake;
                    carInfo.Car_Model             = carModel;
                    carInfo.Car_DUI               = carDUI;
                    carInfo.Car_Num_Speed_Tickets = carSpeedingTickets;
                    carInfo.Car_Coverage_Type     = carCoverage;
                    carInfo.Car_Quote             = total;

                    db.tbl_car.Add(carInfo);
                    db.SaveChanges();

                    return(View("QuotePage", carInfo));
                }
            }
        }
Exemple #4
0
        public ActionResult Create([Bind(Include = "ID,Quote,FirstName,LastName,EmailAddress,MM,DD,YYYY,Year,Make,Model,DUI,Tickets,InsuranceType")] Application application)
        {
            if (ModelState.IsValid)
            {
                decimal driverQuote = 50;

                DateTime DOB = new DateTime(application.YYYY, application.MM, application.DD);
                DateTime now = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day);

                var age = Convert.ToInt16(now - DOB);

                if (age < 25 || age > 100)
                {
                    driverQuote = driverQuote + 25;
                }
                else if (age < 18)
                {
                    driverQuote = driverQuote + 100;
                }


                if (application.Year < 2000 || application.Year > 2015)
                {
                    driverQuote = driverQuote + 25;
                }


                if (application.Make == "Porsche")
                {
                    driverQuote = driverQuote + 25;
                }


                if (application.Make == "Porsche" && application.Model == "911 Carrera")
                {
                    driverQuote = driverQuote + 25;
                }


                if (application.Tickets > 0)
                {
                    driverQuote = driverQuote + (10 * application.Tickets);
                }


                if (application.DUI == "Yes")
                {
                    driverQuote = driverQuote + (driverQuote / 4);
                }


                if (application.InsuranceType == "Full Coverage")
                {
                    driverQuote = driverQuote + (driverQuote / 2);
                }
                application.Quote = driverQuote;
            }

            db.Applications.Add(application);
            db.SaveChanges();
            return(RedirectToAction("Applied"));
        }
        public ActionResult SignUp(string firstName, string lastName, string emailAddress, int age, string carMake, string carModel, int carYear, bool dui, bool fullCoverage, int speedTickets)
        {
            if (string.IsNullOrEmpty(firstName) || string.IsNullOrEmpty(lastName) || string.IsNullOrEmpty(emailAddress) || string.IsNullOrEmpty(carMake) || string.IsNullOrEmpty(carModel))
            {
                return(View("There was an error. Please be sure to fill in all values."));
            }

            decimal quote           = 50;
            decimal duiPercentage   = .25m;
            decimal addFullCoverage = .5m;

            if (age < 25)
            {
                quote += 25;
            }

            else if (age < 18)
            {
                quote += 100;
            }

            else if (age > 100)
            {
                quote += 25;
            }


            if (carYear < 2000)
            {
                quote += 25;
            }

            else if (carYear > 2015)
            {
                quote += 25;
            }


            if (carMake == "Porsche")
            {
                quote += 25;
            }

            else if (carMake == "Porsche" && carModel == "Carerra 911")
            {
                quote += 25;
            }


            if (dui == true)
            {
                quote *= duiPercentage;
            }

            if (speedTickets > 0)
            {
                quote += speedTickets * 10;
            }

            if (fullCoverage == true)
            {
                quote *= addFullCoverage;
            }

            else
            {
                using (InsuranceEntities1 db = new InsuranceEntities1())
                {
                    var insuranceQuote = new InsuranceQuote();
                    insuranceQuote.FirstName    = firstName;
                    insuranceQuote.LastName     = lastName;
                    insuranceQuote.EmailAddress = emailAddress;
                    insuranceQuote.carMake      = carMake;
                    insuranceQuote.carYear      = carYear;
                    insuranceQuote.Dui          = dui;
                    insuranceQuote.fullCoverage = fullCoverage;
                    insuranceQuote.speedTicket  = speedTickets;

                    db.Insurees.Add(insuranceQuote);
                    db.SaveChanges();
                }
            }
        }