Beispiel #1
0
        // GET: Admin
        public ActionResult Index()
        {
            using (InsuranceEntities1 db = new InsuranceEntities1())
            {
                var applications   = db.Applications;
                var applicationVms = new List <ApplicationVM>();
                foreach (var application in applications)
                {
                    var applicationVm = new ApplicationVM();
                    applicationVm.Quote        = application.Quote;
                    applicationVm.FirstName    = application.FirstName;
                    applicationVm.LastName     = application.LastName;
                    applicationVm.EmailAddress = application.EmailAddress;
                    applicationVms.Add(applicationVm);
                }

                return(View(applicationVms));
            }
        }
 // GET: Admin
 public ActionResult Index()
 {
     using (InsuranceEntities1 db = new InsuranceEntities1())
     {
         List <tbl_car>       cars           = db.tbl_car.ToList();
         List <CustomerQuote> customerQuotes = new List <CustomerQuote>();
         foreach (var entry in cars)
         {
             CustomerQuote customerQuote = new CustomerQuote();
             customerQuote.Id           = entry.tbl_customer.Customer_Id;
             customerQuote.FirstName    = entry.tbl_customer.First_Name;
             customerQuote.LastName     = entry.tbl_customer.Last_Name;
             customerQuote.EmailAddress = entry.tbl_customer.Email_Address;
             customerQuote.Quote        = entry.Car_Quote;
             customerQuotes.Add(customerQuote);
         }
         return(View(customerQuotes));
     }
 }
Beispiel #3
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));
                }
            }
        }
Beispiel #4
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));
                }
            }
        }
        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();
                }
            }
        }