Exemplo n.º 1
0
        // PUT api/AutoQuote/5
        public IHttpActionResult PutAutoQuote(int id, AutoQuote autoquote)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != autoquote.Id)
            {
                return(BadRequest());
            }

            db.Entry(autoquote).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!AutoQuoteExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Exemplo n.º 2
0
        //
        // GET: /AutoQuote/Details
        public ActionResult Details()
        {
            var autoQuote = new AutoQuote {
                FirstName = "Angelica", LastName = "Rodriguez", PhoneNumber = "954-662-2188", Email = "*****@*****.**", ZipCode = "33029"
            };

            return(View(autoQuote));
        }
        public ActionResult DeleteConfirmed(int id)
        {
            AutoQuote autoQuote = db.AutoQuotes.Find(id);

            db.AutoQuotes.Remove(autoQuote);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
 public ActionResult Edit([Bind(Include = "AutoQuoteId,InsureeId,BaseRate,AgeUnder18,AgeBtw19and25,Age26andUp,AutoYearBefore2000,AutoYearAfter2015,IsPorsche,IsCarrera,SubTotalBeforeDuiCalc,DuiRateUp25Percent,SubTotalAfterDuiCalc,SpeedingTickets,SubTotalBeforeCoverageCalc,FullCoverageRateUp50Percent,SubTotalAfterCoverageCalc,MonthlyQuoteRate,YearlyQuoteRate")] AutoQuote autoQuote)
 {
     if (ModelState.IsValid)
     {
         db.Entry(autoQuote).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(autoQuote));
 }
Exemplo n.º 5
0
        public IHttpActionResult GetAutoQuote(int id)
        {
            AutoQuote autoquote = db.AutoQuotes.Find(id);

            if (autoquote == null)
            {
                return(NotFound());
            }

            return(Ok(autoquote));
        }
Exemplo n.º 6
0
        public IHttpActionResult PostAutoQuote(AutoQuote autoquote)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.AutoQuotes.Add(autoquote);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = autoquote.Id }, autoquote));
        }
Exemplo n.º 7
0
        protected void Page_Load(object sender, EventArgs e)
        {
            var client = new HttpClient();

            client.BaseAddress = new Uri("http://*****:*****@yahoo.com", ZipCode = "33029"
            };

            client.PostAsJsonAsync("api/AutoQuote", autoquote);
        }
Exemplo n.º 8
0
        public async Task <AutoQuote> Get(int quoteId)
        {
            AutoQuote autoQuote = new AutoQuote();

            using (StreamReader reader = new StreamReader(Path.GetFullPath(AppDomain.CurrentDomain.BaseDirectory) + @"./app_data/auto.leads.json"))
            {
                string jsonResponse = await reader.ReadToEndAsync();

                autoQuote = JsonConvert.DeserializeObject <List <AutoQuote> >(jsonResponse).First(q => q.ID == quoteId);
            }

            return(autoQuote);
        }
 public IActionResult Quote(AutoQuote quote)
 {
     if (ModelState.IsValid)
     {
         quoteService.GenerateAutoQuote(quote);
         return(RedirectToAction("Index", "Insurance"));
     }
     else
     {
         logger.LogInformation("Bad model", quote);
         return(View(quote));
     }
 }
Exemplo n.º 10
0
        public IHttpActionResult DeleteAutoQuote(int id)
        {
            AutoQuote autoquote = db.AutoQuotes.Find(id);

            if (autoquote == null)
            {
                return(NotFound());
            }

            db.AutoQuotes.Remove(autoquote);
            db.SaveChanges();

            return(Ok(autoquote));
        }
        // GET: AutoQuote/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            AutoQuote autoQuote = db.AutoQuotes.Find(id);

            if (autoQuote == null)
            {
                return(HttpNotFound());
            }
            return(View(autoQuote));
        }
Exemplo n.º 12
0
        public ActionResult Create(AutoQuote AutoQuote) //Create(FormCollection collection)
        {
            try
            {
                // TODO: Add insert logic here

                db.AutoQuotes.Add(AutoQuote);
                db.SaveChanges();

                return(View("Success"));
            }
            catch
            {
                return(View());
            }
        }
Exemplo n.º 13
0
 public IActionResult Quote(AutoQuote quote)
 {
     quoteService.GenerateAutoQuote(quote);
     return(RedirectToAction("Index", "Insurance"));
 }
Exemplo n.º 14
0
        public ActionResult QuoteCalculator()
        {
            using (InsuranceEntities db = new InsuranceEntities())
            {
                var insurees   = db.Insurees;
                var autoQuotes = db.AutoQuotes;

                var autoQuoteVMs = new List <AutoQuoteVM>();
                var insureeVMs   = new List <InsureeVM>();

                {
                    foreach (Insuree insuree in insurees)
                    {
                        var autoQuote   = new AutoQuote();
                        var autoQuoteVM = new AutoQuoteVM();
                        var insureeVM   = new InsureeVM();


                        var baseRate = 50.00;


                        var age = DateTime.Now.Year - insuree.DateOfBirth.Year;



                        if (insuree.DateOfBirth.Month > DateTime.Now.Month ||
                            insuree.DateOfBirth.Month == DateTime.Now.Month &&
                            insuree.DateOfBirth.Day > DateTime.Now.Day)
                        {
                            age--;
                        }

                        var insureeAge = Convert.ToInt32(age);


                        double under18    = (insureeAge < 18) ? 100.00 : 0.00;
                        double btw19and25 = ((insureeAge > 18) && (age <= 25)) ? 50.00 : 0.00;
                        double over25     = (insureeAge > 25) ? 25.00 : 0.00;


                        double autoYearPrior2000 = (insuree.CarYear < 2000) ? 25.00 : 0.00;
                        double autoYearAfter2015 = (insuree.CarYear > 2015) ? 25.00 : 0.00;


                        double yesIsPorsche = (insuree.CarMake == "Porsche") ? 25.00 : 0.00;
                        double yesIsCarrera = (insuree.CarModel == "Carrera") ? 25.00 : 0.00;

                        double subtotalBeforeDUI = baseRate + under18 + btw19and25 + over25 +
                                                   autoYearPrior2000 + autoYearAfter2015 + yesIsPorsche +
                                                   yesIsCarrera;

                        int    isTrueDUI        = (insuree.DUI == true) ? 1 : 0;
                        double yesDUI           = subtotalBeforeDUI * 0.25;         //Calculating the rate of increase if DUI is true
                        double duiRate          = (isTrueDUI == 1) ? yesDUI : 0.00; // value that will be placed in Quote DUIRateUP25Percent
                        double subtotalAfterDUI = duiRate + subtotalBeforeDUI;      // value that will be placed in Quote SubTotalAfterDUICalc

                        int    speedingTickets     = insuree.SpeedingTickets;
                        double speedingTicketsRate = speedingTickets * 10.00;

                        double subtotalBeforeCoverageCalc = subtotalAfterDUI + speedingTicketsRate;
                        int    coverageTypeFull           = (insuree.CoverageType == true) ? 1 : 0;
                        double fullCoverageRate           = subtotalBeforeCoverageCalc * 0.50;                 // calculating the rate of increase if FullCoverage is true
                        double yesFullCoverage            = (coverageTypeFull == 1) ? fullCoverageRate : 0.00; //value that will be placed in FullCovRateUP50Percent
                        double subtotalAfterCoverageCalc  = subtotalBeforeCoverageCalc + yesFullCoverage;



                        double monthlyQuote = subtotalAfterCoverageCalc;
                        double yearlyQuote  = subtotalAfterCoverageCalc * 12;

                        insuree.QuoteMonthly                  = Convert.ToDecimal(monthlyQuote);
                        insuree.QuoteYearly                   = Convert.ToDecimal(yearlyQuote);
                        autoQuote.InsureeId                   = Convert.ToInt32(insuree.Id);
                        autoQuote.BaseRate                    = Convert.ToDecimal(baseRate);
                        autoQuote.AgeUnder18                  = Convert.ToDecimal(under18);
                        autoQuote.AgeBtw19and25               = Convert.ToDecimal(btw19and25);
                        autoQuote.Age26andUp                  = Convert.ToDecimal(over25);
                        autoQuote.AutoYearBefore2000          = Convert.ToDecimal(autoYearPrior2000);
                        autoQuote.AutoYearAfter2015           = Convert.ToDecimal(autoYearAfter2015);
                        autoQuote.IsPorsche                   = Convert.ToDecimal(yesIsPorsche);
                        autoQuote.IsCarrera                   = Convert.ToDecimal(yesIsCarrera);
                        autoQuote.SubTotalBeforeDuiCalc       = Convert.ToDecimal(subtotalBeforeDUI);
                        autoQuote.DuiRateUp25Percent          = Convert.ToDecimal(duiRate);
                        autoQuote.SubTotalAfterDuiCalc        = Convert.ToDecimal(subtotalAfterDUI);
                        autoQuote.SpeedingTickets             = Convert.ToDecimal(speedingTicketsRate);
                        autoQuote.SubTotalBeforeCoverageCalc  = Convert.ToDecimal(subtotalBeforeCoverageCalc);
                        autoQuote.FullCoverageRateUp50Percent = Convert.ToDecimal(fullCoverageRate);
                        autoQuote.SubTotalAfterCoverageCalc   = Convert.ToDecimal(subtotalAfterCoverageCalc);


                        insureeVM.QuoteMonthly                  = insuree.QuoteMonthly;
                        insureeVM.QuoteYearly                   = insuree.QuoteYearly;
                        autoQuoteVM.InsureeId                   = autoQuote.InsureeId;
                        autoQuoteVM.BaseRate                    = autoQuote.BaseRate;
                        autoQuoteVM.AgeUnder18                  = autoQuote.AgeUnder18;
                        autoQuoteVM.AgeBtw19and25               = autoQuote.AgeBtw19and25;
                        autoQuoteVM.Age26andUp                  = autoQuote.Age26andUp;
                        autoQuoteVM.AutoYearBefore2000          = autoQuote.AutoYearBefore2000;
                        autoQuoteVM.AutoYearAfter2015           = autoQuote.AutoYearAfter2015;
                        autoQuoteVM.IsPorsche                   = autoQuote.IsPorsche;
                        autoQuoteVM.IsCarrera                   = autoQuote.IsCarrera;
                        autoQuoteVM.SubTotalBeforeDuiCalc       = autoQuote.SubTotalBeforeDuiCalc;
                        autoQuoteVM.DuiRateUp25Percent          = autoQuote.DuiRateUp25Percent;
                        autoQuoteVM.SubTotalAfterDuiCalc        = autoQuote.SubTotalAfterDuiCalc;
                        autoQuoteVM.SpeedingTickets             = autoQuote.SpeedingTickets;
                        autoQuoteVM.SubTotalBeforeCoverageCalc  = autoQuote.SubTotalBeforeCoverageCalc;
                        autoQuoteVM.FullCoverageRateUp50Percent = autoQuote.FullCoverageRateUp50Percent;
                        autoQuoteVM.SubTotalAfterCoverageCalc   = autoQuote.SubTotalAfterCoverageCalc;
                        autoQuoteVM.QuoteMonthly                = autoQuote.QuoteMonthly;
                        autoQuoteVM.QuoteYearly                 = autoQuote.QuoteYearly;



                        db.AutoQuotes.Add(autoQuote);
                        db.Insurees.Add(insuree);
                        db.SaveChanges();
                    }
                    return(View(autoQuoteVMs));
                }
            }
        }
Exemplo n.º 15
0
 public void GenerateAutoQuote(AutoQuote quote)
 {
     // todo
 }
        public ActionResult AutoQuote(string firstName,
                                      string lastName,
                                      string emailAddress,
                                      string dateOfBirth,
                                      string carYear,
                                      string carMake,
                                      string carModel,
                                      string DUI,
                                      string tickets,
                                      string coverage)
        {
            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(coverage))
            {
                return(View("~/Views/Shared/Error.cshtml"));
            }
            else
            {
                int plusAge = 0;
                {
                    int age = CalculateAge(Convert.ToDateTime(dateOfBirth));
                    if (age < 25)
                    {
                        plusAge = plusAge + 25;
                    }
                    else if (age < 18)
                    {
                        plusAge = plusAge + 100;
                    }
                    else if (age > 100)
                    {
                        plusAge = plusAge + 25;
                    }
                }

                int plusCarYear = 0;
                {
                    if (Convert.ToInt32(carYear) < 2000)
                    {
                        plusCarYear = plusCarYear + 25;
                    }
                    else if (Convert.ToInt32(carYear) > 2015)
                    {
                        plusCarYear = plusCarYear + 25;
                    }
                }

                int plusCarMake = 0;
                {
                    string carmake = carMake.ToLower();
                    if (carmake == "porsche")
                    {
                        plusCarMake = plusCarMake + 25;
                    }
                }

                int plusCarModel = 0;
                {
                    string carmodel = carModel.ToLower();
                    if (carmodel == "911 carrera" || carmodel == "carrera" || carmodel == "911")
                    {
                        plusCarModel = plusCarModel + 25;
                    }
                }

                int plusTickets = 0;
                int ticket      = Convert.ToInt32(tickets);
                {
                    if (ticket > 0)
                    {
                        plusTickets = ticket * 10;
                    }
                }

                int    total = plusAge + plusCarYear + plusCarMake + plusCarModel + plusTickets;
                double num1  = Convert.ToDouble(total);
                {
                    if (Convert.ToBoolean(Enum.Parse(typeof(BooleanAliases), DUI)) == true)
                    {
                        num1 = (num1 * 0.25) + num1;
                    }
                }
                double num2 = Convert.ToDouble(total);
                {
                    if (Convert.ToBoolean(Enum.Parse(typeof(BooleanAliases), coverage)) == true)
                    {
                        num2 = (num2 * 0.5) + num2;
                    }
                }
                double totalQuote = 50 + total + num1 + num2;

                using (AutoInsuranceQuoteEntities db = new AutoInsuranceQuoteEntities())
                {
                    var autoquote = new AutoQuote
                    {
                        FirstName    = firstName,
                        LastName     = lastName,
                        EmailAddress = emailAddress,
                        DateOfBirth  = Convert.ToDateTime(dateOfBirth),
                        CarYear      = Convert.ToInt32(carYear),
                        CarMake      = carMake,
                        CarModel     = carModel,
                        DUI          = Convert.ToBoolean(Enum.Parse(typeof(BooleanAliases), DUI)),
                        Tickets      = Convert.ToByte(tickets),
                        Coverage     = Convert.ToBoolean(Enum.Parse(typeof(BooleanAliases), coverage)),
                        Quote        = Convert.ToInt32(totalQuote)
                    };

                    db.AutoQuotes.Add(autoquote);
                    db.SaveChanges();
                }

                ViewBag.Message = "$ " + totalQuote + " / month";
                return(View("Success"));
            }
        }