public ActionResult UpdateAccount() { if (Session["CustomerId"] == null) { TempData["ReasontoLogin"] = "******"; return(RedirectToAction("loginview", "login")); } int custID = Convert.ToInt32(Session["CustomerId"]); UpdateDetailsViewModel viewModel = new UpdateDetailsViewModel(); CustomerDetailsViewModel viewModel2 = new CustomerDetailsViewModel(); var tempCustomer = new HealthInsuranceDB().Customers.Find(custID); viewModel2.CustomerDetail = tempCustomer; viewModel2.CityDetail = new HealthInsuranceDB().Cities.Find(tempCustomer.CityID); viewModel2.StateDetail = new HealthInsuranceDB().States.Find(tempCustomer.StateID); viewModel.FullCustomerDetail = viewModel2; var cities = new HealthInsuranceDB().Cities; viewModel.CityNames = cities.Select(c => new SelectListItem { Text = c.CityName, Value = c.CityID.ToString() }); var states = new HealthInsuranceDB().States; viewModel.StateNames = states.Select(s => new SelectListItem { Text = s.StateName, Value = s.StateID.ToString() }); ViewBag.date = tempCustomer.DateofBirth; return(View(viewModel)); }
public ActionResult DoctorDetail() { if (Session["CustomerId"] == null) { TempData["ReasontoLogin"] = "******"; return(RedirectToAction("loginview", "login")); } int custID = Convert.ToInt32(Session["CustomerId"]); var tempCustomer = new HealthInsuranceDB().Customers.Find(custID); if (tempCustomer.DoctorID == null) { ViewBag.ErrorMsg = "You have not chosen a Doctor Yet"; return(View()); } DoctorDetailsViewModel viewModel = new DoctorDetailsViewModel(); var tempDoc = new HealthInsuranceDB().Doctors.Find(tempCustomer.DoctorID); var tempHospital = new HealthInsuranceDB().Hospitals.Find(tempDoc.HospitalID); viewModel.doctor = new HealthInsuranceDB().Doctors.Find(tempCustomer.DoctorID); viewModel.hospital = new HealthInsuranceDB().Hospitals.Find(tempDoc.HospitalID); ViewBag.City = new HealthInsuranceDB().Cities.Find(tempHospital.CityID).CityName; ViewBag.State = new HealthInsuranceDB().States.Find(tempHospital.StateID).StateName; return(View(viewModel)); }
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 Redirects(int id) { Customer cust = new HealthInsuranceDB().Customers.Find(id); TempData["Customer"] = cust; return(RedirectToAction("AboutQuote", "Quote")); }
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 RetrieveQuote() { int CustomerId = Convert.ToInt32(Session["CustomerId"]); var DB = new HealthInsuranceDB(); Customer cust = DB.Customers.Find(CustomerId); return(View(cust)); }
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() { if (Session["CustomerId"] == null) { TempData["ReasontoLogin"] = "******"; return(RedirectToAction("loginview", "login")); } int custID = Convert.ToInt32(Session["CustomerId"]); var tempClaim = new HealthInsuranceDB().Claims.Create(); tempClaim.CustomerID = custID; return(View(tempClaim)); }
public ActionResult DoctorDetailPopup(int id) { var HIDB = new HealthInsuranceDB(); TempData["DoctorID"] = id; var viewModel = from o in HIDB.Doctors join o2 in HIDB.Cities on o.CityID equals o2.CityID join o3 in HIDB.States on o.StateID equals o3.StateID where o.DoctorID.Equals(id) select new DoctorViewModel { doc = o, citys = o2, states = o3 }; return(View("DoctorDetailPopup", viewModel)); }
public ActionResult FindADoctor() { //TempData["UserID"] = -1; //Guest // get data from DB var HIDB = new HealthInsuranceDB(); // Connect DB to view model var viewModel = from o in HIDB.Doctors join o2 in HIDB.Cities on o.CityID equals o2.CityID join o3 in HIDB.States on o.StateID equals o3.StateID where o.Firstname.Contains("-1") select new DoctorViewModel { doc = o, citys = o2, states = o3 }; return(View("FindADoctor", viewModel)); }
public ActionResult PlanDetail() { if (Session["CustomerId"] == null) { TempData["ReasontoLogin"] = "******"; return(RedirectToAction("loginview", "login")); } int custID = Convert.ToInt32(Session["CustomerId"]); PlanDetailsModelView viewModel = new PlanDetailsModelView(); var tempCustomer = new HealthInsuranceDB().Customers.Find(custID); //Bug here viewModel.PlanCollections = new HealthInsuranceDB().Plans.Where(p => p.CustomerID == custID).ToList(); viewModel.PlanTypeCollections = new HealthInsuranceDB().PlanTypes; return(View(viewModel)); }
public ActionResult forgetpassword(ForgetPass fp) { if (ModelState.IsValid) { var database = new HealthInsuranceDB(); var user = database.Users.ToList(); foreach (var s in user) { if (s.UserName == fp.username) { Session["userid"] = s.UserID.ToString(); return(View("passwordvalidation")); } } } return(View()); }
public ActionResult passwordvalidation(Passvalidation pv) { var database = new HealthInsuranceDB(); var cust = database.Customers.ToList(); var g = Session["userid"]; foreach (var s in cust) { if (s.UserID.ToString() == g.ToString()) { if (s.DateofBirth.Date == pv.passvalidation.Date) { return(RedirectToAction("sendmail", "login")); } } } return(View()); }
public ActionResult Search() { string serachName = Request.Form["SerName"]; string serachType = Request.Form["SerType"]; string serachCity = Request.Form["SerCity"]; var HIDB = new HealthInsuranceDB(); var viewModel = from o in HIDB.Doctors join o2 in HIDB.Cities on o.CityID equals o2.CityID join o3 in HIDB.States on o.StateID equals o3.StateID where o.Firstname.Contains(serachName) where o.DoctorType.Contains(serachType) where o2.CityName.Contains(serachCity) select new DoctorViewModel { doc = o, citys = o2, states = o3 }; return(View("FindADoctor", viewModel)); }
public ActionResult loginview(LoginClass lg) { if (TempData["ReasontoLogin"] != null) { ViewBag.Error = (string)TempData["ReasontoLogin"]; } if (ModelState.IsValid) { var database = new HealthInsuranceDB(); bool t = false; var user = database.Users.ToList(); Session["database"] = database; ViewBag.database = database; int test = 0; foreach (var s in user) { if (s.UserName == lg.txtusername && s.Password == lg.txtpassword) { t = true; Session["UserId"] = s.UserID; foreach (Customer cust in database.Customers) { if (cust.UserID == s.UserID) { Session["CustomerId"] = cust.CustomerID; test = Convert.ToInt32(Session["CustomerId"]); break; } } break; } } if (t == true) { return(RedirectToAction("Index", "Homepage")); } ViewData["wrong"] = 1; return(View()); } else { return(View()); } }
public ActionResult forgetusername(Forgetusername fn) { var database = new HealthInsuranceDB(); var c = database.Customers.ToList(); foreach (var s in c) { if ((s.Firstname == fn.Name) && (s.Lastname == fn.Lastname) && (s.DateofBirth.Date == fn.DOB.Date)) { TempData["forgetusername"] = fn; return(RedirectToAction("sendmail", "login")); // return View("sendmail"); } } return(View()); // return View("sendmail"); }
public ActionResult AboutQuote() { //Let the customer to create a quote if (Session["CustomerId"] == null) { TempData["ReasontoLogin"] = "******"; return(RedirectToAction("loginview", "login")); } int custId = Convert.ToInt32(Session["CustomerId"]); Customer customer = new HealthInsuranceDB().Customers.Find(custId); CustomerQuotePlan CustWithQ = new CustomerQuotePlan() { cust = customer, quote = new Quote(), plan = new Plan() }; ViewBag.City = new HealthInsuranceDB().Cities.Find(customer.CityID).CityName; ViewBag.State = new HealthInsuranceDB().States.Find(customer.CityID).StateName; return(View(CustWithQ)); }
public ActionResult RetrieveQuoteResult() { var DB = new HealthInsuranceDB(); Customer customer = DB.Customers.Find(Convert.ToInt32(Request.Form["customerId"])); Quote q = DB.Quotes.Find(Convert.ToInt32(Request.Form["QuoteId"])); string errorMessage = ""; if (customer == null) { errorMessage = "Sorry, Please Login to see your quote"; } else if (q == null) { errorMessage = "Sorry, We haven't fount any quotes based on your quote id"; } else if (q.CustomerID != customer.CustomerID) { errorMessage = "Sorry, this is not your quote"; } if (errorMessage != "") { ViewBag.error = errorMessage; return(View(customer)); } CustomerQuotePlan CustWithQ = new CustomerQuotePlan() { cust = customer, quote = q, plan = new Plan() }; if (q.StartDate != null) { ViewBag.StartDate = q.StartDate.Value.ToString("yyyy-MM-dd"); } ViewBag.City = DB.Cities.Find(customer.CityID).CityName; ViewBag.State = DB.States.Find(customer.CityID).StateName; return(View("AboutQuote", CustWithQ)); }
// GET: /Account public ActionResult index() { //if (TempData["custID"] == null) return RedirectToAction("index", "Homepage"); //TempData["custID"] = 1; if (Session["CustomerId"] == null) { TempData["ReasontoLogin"] = "******"; return(RedirectToAction("loginview", "login")); } int custID = Convert.ToInt32(Session["CustomerId"]); //TempData.Keep("custID"); var tempCustomer = new HealthInsuranceDB().Customers.Find(custID); var tempClaims = new HealthInsuranceDB().Claims.Where(c => c.CustomerID == 1).ToList(); AccountDetailsViewModel viewModel = new AccountDetailsViewModel() { CustomerDetails = tempCustomer, ClaimsCollection = tempClaims }; ViewBag.City = new HealthInsuranceDB().Cities.Find(tempCustomer.CityID).CityName; ViewBag.State = new HealthInsuranceDB().States.Find(tempCustomer.StateID).StateName; return(View(viewModel)); }
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 sendmail(MailModel _objModelMail) { var s = (Forgetusername)TempData["forgetusername"]; var d = Session["userid"].ToString(); string id = ""; var database = new HealthInsuranceDB(); var User = database.Customers.ToList(); if (s != null) { foreach (var sa in User) { if ((s.Name == sa.Firstname) && (s.Lastname == sa.Lastname)) { id = sa.UserID.ToString(); _objModelMail.To = sa.Email.ToString(); } } if (id != "") { var tmp = database.Users.ToList(); foreach (var sa in tmp) { if (sa.UserID.ToString() == id) { _objModelMail.Body = "your user name is : " + sa.UserName.ToString();// aqui es k va el password } _objModelMail.Subject = "Forget username"; } } // part to send the msg _objModelMail.From = "*****@*****.**"; MailMessage mail = new MailMessage(); mail.To.Add(_objModelMail.To); mail.From = new MailAddress(_objModelMail.From); mail.Subject = _objModelMail.Subject; string Body = _objModelMail.Body; mail.Body = Body; mail.IsBodyHtml = true; SmtpClient smtp = new SmtpClient(); smtp.Host = "smtp.gmail.com"; smtp.Port = 587; smtp.UseDefaultCredentials = false; smtp.Credentials = new System.Net.NetworkCredential ("cignaprojectgroup", "MvcProject02");// Enter seders User name and password smtp.EnableSsl = true; smtp.Send(mail); return(View("homepage")); } else if (d != null) { foreach (var sa in User) { if (sa.UserID.ToString() == d) { id = sa.UserID.ToString(); _objModelMail.To = sa.Email.ToString(); } } if (id != "") { var tmp = database.Users.ToList(); foreach (var sa in tmp) { if (sa.UserID.ToString() == id) { _objModelMail.Body = "your user passwor is : " + sa.Password.ToString();// aqui es k va el password } _objModelMail.Subject = "Forget password"; } } // part to send the msg _objModelMail.From = "*****@*****.**"; MailMessage mail = new MailMessage(); mail.To.Add(_objModelMail.To); mail.From = new MailAddress(_objModelMail.From); mail.Subject = _objModelMail.Subject; string Body = _objModelMail.Body; mail.Body = Body; mail.IsBodyHtml = true; SmtpClient smtp = new SmtpClient(); smtp.Host = "smtp.gmail.com"; smtp.Port = 587; smtp.UseDefaultCredentials = false; smtp.Credentials = new System.Net.NetworkCredential ("cignaprojectgroup", "MvcProject02");// Enter seders User name and password smtp.EnableSsl = true; smtp.Send(mail); return(View("homepage")); } return(View("homepage")); }
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()); }