public JsonResult SaveQuote(string cid, string qid, string qsd, string ppd) { //Save the quote created to the database, if not int QuoteId = Convert.ToInt32(qid); int CustomerId = Convert.ToInt32(cid); int Period = Convert.ToInt32(ppd); var HealthDB = new HealthInsuranceDB(); Quote q = HealthDB.Quotes.Find(QuoteId); Customer CurrentCust = HealthDB.Customers.Find(CustomerId); string start = qsd; if (q == null) { //Create a quote based on the information q = new Quote() { QuoteName = "Regular " + CurrentCust.Firstname, QuoteDescription = "Regular", QuoteFee = 200 * Period, CustomerID = CustomerId, ExpireDate = DateTime.Now.AddDays(30), IsActive = false }; if (start != "") { q.StartDate = Convert.ToDateTime(start); q.EndDate = q.StartDate.Value.AddDays(Period * 30); } ; try { HealthDB.Quotes.Add(q); HealthDB.SaveChanges(); } catch (DataException) { ModelState.AddModelError("", "Unable to save changes. Try again, and if the problem persists see your system administrator."); } } else { //Update the quote information q.QuoteFee = 200 * Period; q.CustomerID = CustomerId; q.IsActive = false; if (start != "") { q.StartDate = Convert.ToDateTime(start); q.EndDate = q.StartDate.Value.AddDays(Period * 30); } ; HealthDB.SaveChanges(); } return(Json(q.QuoteID, JsonRequestBehavior.AllowGet)); }
public ActionResult DeclareClaim(Claim claim) { if (ModelState.IsValid) { var db = new HealthInsuranceDB(); HashSet <Agent> agentSet = new HashSet <Agent>(); foreach (var c in db.Agents) { agentSet.Add(c); } List <Agent> agentList = agentSet.ToList(); Random rand = new Random(); int iup = agentList.Count() - 1; int idown = 0; int result = rand.Next(idown, iup); Agent temp = agentList.ElementAt(result); int agentID = temp.AgentID; db.Claims.Add(new Claim { CustomerID = claim.CustomerID, AgentID = agentID, ClaimStatus = "Processing Claim", DeclareDate = System.DateTime.Now, AmountPaid = null, PaidDate = null, Description = claim.Description }); db.SaveChanges(); return(RedirectToAction("index")); } return(View(claim)); }
public ActionResult UpdateAccount(UpdateDetailsViewModel viewModel) { if (ModelState.IsValid) { DateTime date = viewModel.FullCustomerDetail.CustomerDetail.DateofBirth; var db = new HealthInsuranceDB(); Customer tempCustomer = new Customer(); tempCustomer = db.Customers.Find(viewModel.FullCustomerDetail.CustomerDetail.CustomerID); tempCustomer.CustomerID = viewModel.FullCustomerDetail.CustomerDetail.CustomerID; tempCustomer.Address = viewModel.FullCustomerDetail.CustomerDetail.Address; if (viewModel.FullCustomerDetail.CustomerDetail.Gender) { tempCustomer.Gender = true; } else { tempCustomer.Gender = false; } tempCustomer.DateofBirth = date; tempCustomer.Phone = viewModel.FullCustomerDetail.CustomerDetail.Phone; tempCustomer.DoctorID = viewModel.FullCustomerDetail.CustomerDetail.DoctorID; tempCustomer.Email = viewModel.FullCustomerDetail.CustomerDetail.Email; tempCustomer.Firstname = viewModel.FullCustomerDetail.CustomerDetail.Firstname; tempCustomer.Lastname = viewModel.FullCustomerDetail.CustomerDetail.Lastname; tempCustomer.SSN = viewModel.FullCustomerDetail.CustomerDetail.SSN; tempCustomer.Zip = viewModel.FullCustomerDetail.CustomerDetail.Zip; tempCustomer.UserID = viewModel.FullCustomerDetail.CustomerDetail.UserID; tempCustomer.CityID = viewModel.CitySelectedID; tempCustomer.StateID = viewModel.StateSelectedID; db.Entry(tempCustomer).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); return(RedirectToAction("index")); } return(View(viewModel)); }
public ActionResult preregistration(Registration1 r) { if (ModelState.IsValid) { var database = new HealthInsuranceDB(); var s = new HealthInsuranceDB().Users.Create(); var cc = database.Users.ToList(); // cheking to see if phone , username, and email are unique foreach (var h in cc) { if (h.UserName == r.username) { ViewBag.error = " Username already exist"; return(View()); } } // end of cheking for unique if (r.username != null) { if (r.password != r.repassword) { return(View()); } s.UserName = r.username; s.Password = r.password; s.CreID = 1; database.Users.Add(s); database.SaveChanges(); var database1 = new HealthInsuranceDB(); var user = database.Users.ToList(); int x = -1; foreach (var item in user) { if (item.UserName == s.UserName && item.Password == s.Password) { x = item.UserID; } } TempData["userid"] = x; return(View("registrationview")); } } if (TempData["userid"] != null) { return(View("registrationview")); } return(View()); }
public ActionResult registrationview(Registration r) { if (TempData["userid"] == null) { return(View("preregistration")); } else if (ModelState.IsValid) { var database = new HealthInsuranceDB(); var cc = database.Customers.ToList(); var c = new HealthInsuranceDB().Customers.Create(); // cheking to see if phone , username, and email are unique foreach (var h in cc) { if (h.Email == r.email || h.Phone == r.phone || h.SSN == r.SSN) { ViewBag.error = " check your email, phone or ssn "; return(View()); } } // end of cheking for unique c.UserID = Convert.ToInt32(TempData["userid"]); // int int c.Address = r.address; // string nvarchar(20); c.DateofBirth = DateTime.Now; //Convert.ToDateTime( "1990-08-01"); c.Email = r.email; // string nvarchar(100) c.Firstname = r.name; // string nvarchar(20) c.Lastname = r.lastname; // nvarchar(20) string //should check for unique c.SSN = r.SSN; //string nvarchar(20) // c.DoctorID = null; //should check for unique c.Phone = r.phone; //nvarchar(20) //CityID and StateID should be set with user input c.CityID = 5; // int c.StateID = 3; // int c.Zip = r.zipcode; //What if user type into a "Male", female then? if (r.gender == "man") { c.Gender = false; } else { c.Gender = true; // boolean bit } database.Customers.Add(c); database.SaveChanges(); return(View("homepage")); } else { TempData.Keep("userid"); } return(View()); }
public ActionResult BuyQuote() { //Quote and Plan Information int QuoteId = Convert.ToInt32(Request.Form["QuoteID"]); int CustomerId = Convert.ToInt32(Request.Form["CustID"]); int Period = Convert.ToInt32(Request.Form["PayPeriod"]); int quotefee = 0; string quoteDescription = Request.Form["QuoteDescription"]; string MedicalPlan = Request.Form["MedicalPlan"]; string DentalPlan = Request.Form["DentalPlan"]; string EyePlan = Request.Form["EyePlan"]; string start = Request.Form["QuoteStartDate"]; if (quoteDescription == "Silver") { quotefee = 200; } if (quoteDescription == "Gold") { quotefee = 300; } if (quoteDescription == "Platinum") { quotefee = 400; } //DAL Layer to access to the database var HealthDB = new HealthInsuranceDB(); Quote q = HealthDB.Quotes.Find(QuoteId); Customer CurrentCust = HealthDB.Customers.Find(CustomerId); //Handle Quote Problem if (q == null) { //Create a quote based on the information q = new Quote() { QuoteName = quoteDescription + " " + CurrentCust.Firstname, QuoteDescription = quoteDescription, QuoteFee = quotefee * Period, CustomerID = CustomerId, StartDate = Convert.ToDateTime(start), IsActive = true }; q.EndDate = q.StartDate.Value.AddDays(Period * 30); q.ExpireDate = q.EndDate.Value.AddDays(30); try { HealthDB.Quotes.Add(q); HealthDB.SaveChanges(); } catch (DataException) { ModelState.AddModelError("", "Unable to save changes. Try again, and if the problem persists see your system administrator."); } } else { q.QuoteName = quoteDescription + " " + CurrentCust.Firstname; q.QuoteDescription = quoteDescription; q.QuoteFee = quotefee * Period; q.CustomerID = CustomerId; q.StartDate = Convert.ToDateTime(start); q.IsActive = true; q.EndDate = q.StartDate.Value.AddDays(Period * 30); q.ExpireDate = q.EndDate.Value.AddDays(30); HealthDB.SaveChanges(); } //Handle Plan Problem if (MedicalPlan != "") { Plan p = new Plan { PlanTypeID = 1, PlanFee = 60, PlanDescription = CurrentCust.Firstname, StartDate = Convert.ToDateTime(start), CustomerID = CustomerId }; p.EndDate = p.StartDate.AddDays(Period * 30); HealthDB.Plans.Add(p); HealthDB.SaveChanges(); } if (DentalPlan != "") { Plan p = new Plan { PlanTypeID = 2, PlanFee = 70, PlanDescription = CurrentCust.Firstname, StartDate = Convert.ToDateTime(start), CustomerID = CustomerId }; p.EndDate = p.StartDate.AddDays(Period * 30); HealthDB.Plans.Add(p); HealthDB.SaveChanges(); } if (EyePlan != "") { Plan p = new Plan { PlanTypeID = 3, PlanFee = 80, PlanDescription = CurrentCust.Firstname, StartDate = Convert.ToDateTime(start), CustomerID = CustomerId }; p.EndDate = p.StartDate.AddDays(Period * 30); HealthDB.Plans.Add(p); HealthDB.SaveChanges(); } ViewBag.CustId = CurrentCust.CustomerID; ViewBag.QuoteId = q.QuoteID; return(View()); }