//=============================================================================================== public ActionResult CreateCustomerPolicy() { if (Session["id"] != null) { //Get Customer int id = (int)Session["id"]; CustomerinfoDAORequest request = new CustomerinfoDAORequest(); CustomerinfoViewModel customer = request.GetCustomerById(id); ViewData["Customers"] = customer; //Get Policy int policyID = (int)TempData["PolicyID"]; PolicyDAORequest request1 = new PolicyDAORequest(); PolicyViewModel policy = request1.GetPolicyById(policyID); ViewData["Policies"] = policy; ViewData["Brands"] = GetBrandList(); //Get Total Payment PolicyTypeDAORequest request2 = new PolicyTypeDAORequest(); PolicytypeViewModel type = request2.GetTypeById(policy.policytypeid); ViewBag.Price = (decimal)(type.price * policy.policyduration); return(View()); } return(View()); }
public ActionResult AddACC(CustomerinfoViewModel cus) { ss.Add(cus); List <CustomerinfoViewModel> c = ss.GetAll(); Session["AllListAcc"] = c; return(RedirectToAction("ViewAllAcc")); }
public bool CheckNullField(CustomerinfoViewModel c) { if (c.name != null && c.dob != null && c.address != null && c.phone != null && c.email != null && c.address != null && c.username != null && c.password != null) { return(true); } return(false); }
public ActionResult EditAcc(int id) { CustomerinfoViewModel asf = ss.GetEdit(id); List <UsertypeViewModel> q = cc.GetAll(); Session["AllListUsType"] = q; ViewData["AllListAcc"] = asf; return(View()); }
public ActionResult NewAcc(CustomerinfoViewModel cus) { ss.Update(cus); List <CustomerinfoViewModel> c = ss.GetAll(); Session["AllListAcc"] = c; if (Session["cusSearch"] == null) { return(RedirectToAction("ViewAllAcc")); } return(RedirectToAction("AccSearch")); }
public ActionResult RegisterDb(CustomerinfoViewModel uv) { using (var ctx = new InsuranceDbContext()) { if (Session["id"] == null) { if (CheckNullField(uv)) { if (CheckExistUsername(uv.username)) { if (CheckPasswordMatch(uv.password, Request.Params["pwRePassword"])) { if (uv.active == true) { CustomerinfoDAORequest request = new CustomerinfoDAORequest(); //Usertype: Customer uv.user_type_id = 2; request.Add(uv); return(RedirectToAction("Index", "Home")); } else { TempData["Alert"] = "Please Check to Accept Policy"; return(RedirectToAction("Register", "Register")); } } else { TempData["Alert"] = "The Password Not Match"; return(RedirectToAction("Register", "Register")); } } else { TempData["Alert"] = "This Username Already Exist "; return(RedirectToAction("Register", "Register")); } } else { TempData["Alert"] = "Please Enter Full Of Field"; return(RedirectToAction("Register", "Register")); } } else { TempData["Alert"] = "Please Use Another Acount"; return(RedirectToAction("Register", "Register")); } } }
public ActionResult ForgetPasswordDB(CustomerinfoViewModel model) { CustomerinfoDAORequest request = new CustomerinfoDAORequest(); string username = model.username; string email = model.email; ForgetPasswordEmailViewModel emailModel = new ForgetPasswordEmailViewModel(); CustomerinfoViewModel customer = request.GetByUsernameAndEmail(username, email); if (CheckForgotPwNull(username, email)) { if (customer != null) { string realPassword = PasswordSecurity.Decrypt(customer.password); emailModel.From = "*****@*****.**"; emailModel.To = email; emailModel.Subject = "Kraken Force Inc - Your Password"; emailModel.Body = "Your Password is: " + realPassword; MailMessage mail = new MailMessage(); mail.To.Add(emailModel.To); mail.From = new MailAddress(emailModel.From); mail.Subject = emailModel.Subject; mail.Body = emailModel.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("*****@*****.**", "Toan.123"); // Enter seders User name and password smtp.EnableSsl = true; smtp.Send(mail); TempData["AlertForgetPw"] = "Send Email. Check Email to Get Password"; return(RedirectToAction("ForgetPassword")); } else { TempData["AlertForgetPw"] = "Your Username and Email is Wrong. Please try again"; return(RedirectToAction("ForgetPassword")); } } else { TempData["AlertForgetPw"] = "Please Input full field"; return(RedirectToAction("ForgetPassword")); } }
public JsonResult CheckValidUser(CustomerinfoViewModel model) { using (var ctx = new InsuranceDbContext()) { var ecrtPassword = PasswordSecurity.Encrypt(model.password); string result = "Fail"; var DataItem = ctx.Customer_Info.Where(x => x.username == model.username && x.password.Equals(ecrtPassword)).SingleOrDefault(); if (DataItem != null) { Session["id"] = DataItem.id.ToString(); Session["username"] = DataItem.username.ToString(); result = "Success"; } return(Json(result, JsonRequestBehavior.AllowGet)); } }
public ActionResult LoginDB(CustomerinfoViewModel uv) { using (var ctx = new InsuranceDbContext()) { string pw = uv.password; if (Session["id"] == null) { var ecrtPassword = PasswordSecurity.Encrypt(pw); var checkus = ctx.Customer_Info .Where(a => a.username.Equals(uv.username)) .FirstOrDefault(); if (checkus != null) { var obj = ctx.Customer_Info.Where(a => a.username.Equals(uv.username) && a.password.Equals(ecrtPassword)).FirstOrDefault(); if (obj != null) { var ut = ctx.User_Type.Where(t => t.id == obj.user_type_id).Select(t => t.name).FirstOrDefault().ToString(); var sta = obj.active == true ? "Unlock" : "Lock"; if (sta == "Unlock") { if (ut == "Admin") { Session["id"] = obj.id; Session["username"] = obj.username; Session["User_Type"] = ctx.User_Type.Where(utt => utt.id == obj.id).Select(utt => utt.name).FirstOrDefault(); //TempData["Alert"] = "Welcome admin!"; return(RedirectToAction("DashIndex", "DashBoard")); } else { Session["id"] = obj.id; Session["username"] = obj.username; Session["User_Types"] = ctx.User_Type.Where(utt => utt.id == obj.id).Select(utt => utt.name).FirstOrDefault(); //TempData["Alert"] = "Have a nice day!"; return(RedirectToAction("Index", "Home")); } } else { TempData["Alert"] = "Your account has been locked!"; return(RedirectToAction("Login", "Login")); } } else { TempData["Alert"] = "Your password is wrong!"; return(RedirectToAction("Login", "Login")); } } else { TempData["Alert"] = "Your account not exist!"; return(RedirectToAction("Login", "Login")); } } else { TempData["Alert"] = "Please log out to be able to log in with another account!"; return(RedirectToAction("Index", "Home")); } } }