public ResultData _Forget(string Identity, string Email) { if (!string.IsNullOrEmpty(Identity) && !string.IsNullOrEmpty(Email)) { CustomerMapDao map = new CustomerMapDao(); var obj = map.FindByIdentityAndEmail(Identity.Trim(), Email.Trim()); if (obj != null) { String newPass = Helplibery.CreatePassword(10); // Method ส่ง Email obj.Password = Encryption.Encrypt(newPass); map.AddOrUpdate(obj); map.CommitChange(); Log_Customer_reset_passMapDao logmap = new Log_Customer_reset_passMapDao(); logmap.Add(new Log_Customer_reset_pass { CreateDate = DateTime.Now, EmailTo = Email, ErrorText = "", IPAddress = Extension.GetIPAddress(), Result = true }); logmap.CommitChange(); if (!string.IsNullOrEmpty(Email)) { // string ttt = System.Web.Mvc.Html.PartialExtensions.Partial("ChangePassword", obj); string filePath = Path.Combine(HttpRuntime.AppDomainAppPath, "Templates/ChgPass.htm"); string html = System.IO.File.ReadAllText(filePath); SendEmail.SendMail(Email, "แก้ไขรหัสผ่านสํานักงานคณะกรรมการคุ้มครองผู้บริโภค", string.Format(html, obj.FullNameStr, obj.IdentityID, Encryption.Decrypt(obj.Password), obj.Email)); //SendMail.Send(obj.Email, "สํานักงานคณะกรรมการคุ้มครองผู้บริโภค ยินดีต้อนรับเข้าสู่การเป็นสมาชิก", RenderPartialViewToString("ChangePassword", obj)); } return(new ResultData() { Status = true, text = "รหัสผ่านใหม่ ถูกจัดส่งไปยังอีเมลของท่าน เรียบร้อยแล้ว" }); } else { return(new ResultData() { Status = false, text = "ข้อมูลไม่ถูกต้อง" }); } } else { return(new ResultData() { Status = false, text = "กรุณากรอกข้อมูลให้ครบถ้วน" }); } }
public ActionResult RegisterEN(Customer_Oversea obj) { if (ModelState.IsValid) { if (TempData["Customer"] != null) { CustomerMapDao Map = new CustomerMapDao(); Customer Cusobj = new Customer(); Cusobj = (Customer)TempData["Customer"]; Cusobj.Keygen = Guid.NewGuid().ToString(); Cusobj.CreateDate = DateTime.Now; Cusobj.Active = true; Cusobj.IsConfirmRegister = false; Cusobj.IsOversea = true; Cusobj.DateOfBirth = Cusobj.DateOfBirthStr.todate(); //obj.Password = Helplibery.CreatePassword(8); //Cusobj.Password = Encryption.Encrypt("12345678"); Cusobj.Password = Encryption.Encrypt(Helplibery.CreatePassword(8)); //Cusobj.Password = Helplibery.CreatePassword(10); Map.Add(Cusobj); Map.CommitChange(); int ID = GetAccount.GetCustomerLastID(); Customer_OverseaMapDao OverMap = new Customer_OverseaMapDao(); obj.CustomerID = ID; if (obj.PurposeIList != null) { obj.purpose_id = Convert.ToInt32(string.Join(",", obj.PurposeIList)); } OverMap.Add(obj); OverMap.CommitChange(); ////////////////////////////////////////////////////////////////////////////////////////////////////////// CustomerMapDao map = new CustomerMapDao(); if (map.FindIdentityCard(Cusobj.IdentityID).Count == 0) { //obj.IdentityID = obj.IdentValid.UrlDescriptHttp(); int CusID = SaveAccount.Register(Cusobj.IdentityID, Cusobj.TitleID, Cusobj.Fname, Cusobj.Lname, Cusobj.Sex, Cusobj.DateOfBirthStr, Cusobj.Address, Cusobj.DistrictID, Cusobj.PrefectureID, Cusobj.ProvinceID, Cusobj.ZipCode, Cusobj.Tel, Cusobj.Tel_ext, Cusobj.Mobile, Cusobj.Fax, Cusobj.Email, Cusobj.OccupationID, Cusobj.SalaryID, Cusobj.TypeCustomer, Cusobj.FromApp, Cusobj.IsOversea); CustomerMapDao _CusMap = new CustomerMapDao(); Cusobj = _CusMap.FindById(CusID); if (!string.IsNullOrEmpty(Cusobj.Email)) { SendEmail.SendMail(Cusobj.Email, "สํานักงานคณะกรรมการคุ้มครองผู้บริโภค ยินดีต้อนรับเข้าสู่การเป็นสมาชิก", RenderPartialViewToString("regisTemplate", Cusobj)); //SendMail.Send(obj.Email, "สํานักงานคณะกรรมการคุ้มครองผู้บริโภค ยินดีต้อนรับเข้าสู่การเป็นสมาชิก", RenderPartialViewToString("ChangePassword", obj)); } return(Json(new ResultData() { Status = true, text = Url.Action("Index", "Home") }, JsonRequestBehavior.AllowGet)); } else { //return Json(new ResultData() { Status = false, text = Resources.Message.MsgDuplicate }, JsonRequestBehavior.AllowGet); CustomerMapDao _CusMap = new CustomerMapDao(); int CusID = GetAccount.GetCustomerLastID(); if (!string.IsNullOrEmpty(Cusobj.Email)) { SendEmail.SendMail(Cusobj.Email, "สํานักงานคณะกรรมการคุ้มครองผู้บริโภค ยินดีต้อนรับเข้าสู่การเป็นสมาชิก", RenderPartialViewToString("regisTemplate", Cusobj)); //SendMail.Send(obj.Email, "สํานักงานคณะกรรมการคุ้มครองผู้บริโภค ยินดีต้อนรับเข้าสู่การเป็นสมาชิก", RenderPartialViewToString("ChangePassword", obj)); } return(Json(new ResultData() { Status = true, text = Url.Action("Index", "Home") }, JsonRequestBehavior.AllowGet)); } ////////////////////////////////////////////////////////////////////////////////////////////////////////// return(Json(new ResultData() { Status = true, text = Url.Action("Index", "Home") }, JsonRequestBehavior.AllowGet)); //return Json(new { RedirectUrl = Url.Action("Index", "Home") }); } } return(View(obj)); }