Beispiel #1
0
        //===============================================================================================

        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());
        }
Beispiel #2
0
        public ActionResult CreateNewCustomerPolicy()
        {
            int cusId = (int)Session["id"];
            CustomerinfoDAORequest customerRequest = new CustomerinfoDAORequest();
            Customer_Info          customerInfo    = customerRequest.searchCustomerById(cusId);

            int policyID = int.Parse(Request.Params["idPolicyHidden"]);
            PolicyDAORequest policyRequest = new PolicyDAORequest();
            Policy           policyInfo    = policyRequest.searchPolicyById(policyID);

            int             modelId = int.Parse(Request.Params["cbVehicleModel"]);
            ModelDAORequest dao     = new ModelDAORequest();
            Model           model1  = dao.searchModelByModel(modelId);
            ModelViewModel  model   = dao.GetModelById(modelId);

            int vehicleCondition = int.Parse(Request.Params["condition"]);

            Vehicle_Info newVehicle = new Vehicle_Info()
            {
                brand_id          = int.Parse(Request.Form["cbVehicleBrand"]),
                model_id          = int.Parse(Request.Form["cbVehicleModel"]),
                address           = Request.Form["address"].ToString(),
                owner_name        = Request.Form["ownerName"].ToString(),
                version           = Request.Params["version"],
                frame_number      = Request.Params["frameNumber"],
                engine_number     = Request.Params["engineNumber"],
                vehicle_number    = Request.Params["vehicleNumber"],
                vehicle_condition = vehicleCondition,
                rate_by_condition = (vehicleCondition * model.rate) / 100,
                Model             = model1
            };

            Customer_Policy newCustomerPolicy = new Customer_Policy()
            {
                customer_id        = cusId,
                policy_id          = policyID,
                Vehicle_Info       = newVehicle,
                vehicle_id         = newVehicle.id,
                policy_start_date  = DateTime.Parse(Request.Params["startDate"]),
                policy_end_date    = DateTime.Parse(Request.Params["endDate"]),
                create_date        = DateTime.Parse(Request.Params["createDate"]),
                customer_add_prove = "Proved",
                total_payment      = decimal.Parse(Request.Params["totalPayment"]),
                active             = true,
                Policy             = policyInfo,
                Customer_Info      = customerInfo
            };

            CheckoutInfo checkout = new CheckoutInfo()
            {
                CustomerPolicy = newCustomerPolicy,
                Vehicle        = newVehicle
            };

            Session["checkoutInfo"] = checkout;
            return(RedirectToAction("CheckOutPage"));
        }
Beispiel #3
0
        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"));
                }
            }
        }
Beispiel #4
0
        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"));
            }
        }
Beispiel #5
0
        public ActionResult UpdatePassword()
        {
            int    id                      = (int)Session["id"];
            string oldPassword             = Request.Params["oldPassword"];
            string newPassword             = Request.Params["newPassword"];
            string reNewPassword           = Request.Params["reNewPassword"];
            CustomerinfoDAORequest request = new CustomerinfoDAORequest();
            var customer                   = request.GetCustomerById(id);

            if (!CheckNullField(oldPassword, newPassword, reNewPassword))
            {
                if (CheckOldPassword(customer.password, oldPassword))
                {
                    if (CheckMatchNewPassword(newPassword, reNewPassword))
                    {
                        customer.password = PasswordSecurity.Encrypt(newPassword);
                        request.Update(customer);
                        return(RedirectToAction("Index"));
                    }
                    else
                    {
                        TempData["Alert"] = "New password not match";
                        return(RedirectToAction("ChangePassword"));
                    }
                }
                else
                {
                    TempData["Alert"] = "Old Password is not corrent";
                    return(RedirectToAction("ChangePassword"));
                }
            }
            else
            {
                TempData["Alert"] = "Please Enter All Of Field";
                return(RedirectToAction("ChangePassword"));
            }
        }