public ActionResult Password(LocalPasswordModel obj) { if (ModelState.IsValid) { CustomerMapDao map = new CustomerMapDao(); var _obj = map.FindById(Helplibery.GetUserID()); if (_obj.Password == Encryption.Encrypt(obj.OldPassword)) { _obj.Password = Encryption.Encrypt(obj.NewPassword.Trim()); map.AddOrUpdate(_obj); map.CommitChange(); if (!string.IsNullOrEmpty(_obj.Email)) { //ChangePasswordViewModel newObj = new ChangePasswordViewModel(); //newObj.ConfirmPassword = obj.NewPassword; //newObj.NewPassword = obj.NewPassword; //newObj.OldPassword = obj.OldPassword; SendEmail.SendMail(_obj.Email, "แก้ไขรหัสผ่านสํานักงานคณะกรรมการคุ้มครองผู้บริโภค", RenderPartialViewToString("ChangePasswordTemplate", _obj)); //SendMail.Send(obj.Email, "สํานักงานคณะกรรมการคุ้มครองผู้บริโภค ยินดีต้อนรับเข้าสู่การเป็นสมาชิก", RenderPartialViewToString("ChangePassword", obj)); } return(Json(new ResultData() { Status = true, text = Url.Action("Index", "Manage") }, JsonRequestBehavior.AllowGet)); } } ModelState.AddModelError("", "ข้อมูลไม่ถูกต้อง"); return(Json(new ResultData() { Status = false, text = "ข้อมูลไม่ถูกต้อง" }, JsonRequestBehavior.AllowGet)); }
public void Get(string ID, string UserKeys, string Oldpass, string newPass, string PassCompare) { //_MChange(Identity, Email); int _id = MobileEncryption.Decrypt(ID.UrlDescriptHttp()).Toint(); string Key = MobileEncryption.Decrypt(UserKeys.UrlDescriptHttp()); CustomerMapDao map = new CustomerMapDao(); var _obj = map.FindByActive().Where(o => o.ID == _id && o.Keygen == Key).FirstOrDefault(); result = falseresult("ข้อมูลไม่ถูกต้อง"); if (newPass == PassCompare || _obj != null) { if (_obj.Password == Encryption.Encrypt(Oldpass)) { _obj.Password = Encryption.Encrypt(newPass); map.AddOrUpdate(_obj); map.CommitChange(); result = Trueresult("แก้ไขข้อมูลเรียบร้อยแล้ว"); } } HttpContext.Current.Response.ContentType = "application/json"; HttpContext.Current.Response.Write(JsonConvert.SerializeObject(result)); HttpContext.Current.Response.End(); }
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 = "กรุณากรอกข้อมูลให้ครบถ้วน" }); } }
private void _AddComplain(string tokenId, string Identification_number, string Consumer_firstname, string Consumer_lastname, string Consumer_gender, string Consumer_Birth , string Consumer_Address, string Consumer_ZipCode, string Consumer_Tel, string Consumer_Tel_Ex, string Consumer_Mobile, string Consumer_Fax, string Consumer_Email, string Complain_Subject , string Complain_Details, string DefendentName, string DefendentDescription, string Payment, string PlacePurchase, string Motive, string IsOversea, string OverseaAddress) { if (string.IsNullOrEmpty(tokenId)) { result = falseresult("UnAuthorized."); } if (string.IsNullOrEmpty(Identification_number)) { result = falseresult("Please provide Identification number."); } //string key = Encryption.Decrypt(tokenId); //if (!IsValidateToken(key)) // result = falseresult("UnAuthorized."); if (!IsValidateToken(tokenId)) { result = falseresult("UnAuthorized."); } try { Department_ExMapDao _departMap = new Department_ExMapDao(); AuthenticateTokenMapDao _authenMap = new AuthenticateTokenMapDao(); CustomerMapDao _cusMap = new CustomerMapDao(); CustomerVerifyMapDao _mapVer = new CustomerVerifyMapDao(); ComplainsMapDao _Map = new ComplainsMapDao(); Complains_WebService_logMapDao _logMap = new Complains_WebService_logMapDao(); Complains _Item = new Complains(); //var objToken = _authenMap.FindByKeygen(key).FirstOrDefault(); //if (objToken != null) //{ string Complain_Code_ID = null; var Dep_ex = _departMap.FindByKeygen(TokenValid.ApiKey).FirstOrDefault(); int? ChannelID = Dep_ex.ChanelID; int? CusID = SaveAccount.CheckUserAndNewregis(null, Identification_number, Consumer_firstname, Consumer_lastname, Consumer_gender, Consumer_Birth, Consumer_Address, null, null, null, Consumer_ZipCode, Consumer_Tel, Consumer_Tel_Ex, Consumer_Mobile, Consumer_Fax, Consumer_Email, false, null, null); if (IsOversea.ToUpper().Trim() == "TRUE") { var CusObj = _cusMap.FindById(CusID.Toint()); CusObj.IsOversea = true; _cusMap.AddOrUpdate(CusObj); _cusMap.CommitChange(); Customer_OverseaMapDao OverSeaMap = new Customer_OverseaMapDao(); if (OverSeaMap.FindAll().Where(o => o.CustomerID == CusID).ToList().Count() == 0) { Customer_Oversea SMapObj = new Customer_Oversea(); SMapObj.CustomerID = CusID; SMapObj.address_oversea = OverseaAddress; OverSeaMap.Add(SMapObj); OverSeaMap.CommitChange(); } } int Id = SaveComplain.AddnewComplain(Complain_Subject, ChannelID, CusID, DefendentName, DefendentDescription, Complain_Details , null, null, null, null, PlacePurchase, null, Payment, null, Motive, null, null, ref Complain_Code_ID); SaveComplain.StartTrack(Id, 3, TokenValid.ApiKey, null); _Item = _Map.FindById(Id); //*********************Save Complain Service Log Complains_WebService_log _log = new Complains_WebService_log(); _log.IdentityID = Identification_number; _log.Sex = Consumer_gender != null?Consumer_gender.ToLower() : ""; _log.ApiKey = TokenValid.ApiKey; _log.CreateDate = DateTime.Now; _log.FullName = Consumer_firstname + " " + Consumer_lastname; // _log.TitleID = TitleID; _log.Fname = Consumer_firstname; _log.Lname = Consumer_lastname; _log.DateOfBirth = Consumer_Birth; _log.Address = Consumer_Address; _log.ZipCode = Consumer_ZipCode; _log.Tel = Consumer_Tel; _log.Tel_ext = Consumer_Tel_Ex; _log.Mobile = Consumer_Mobile; _log.Fax = Consumer_Fax; _log.Email = Consumer_Email; _log.Complain_Subject = Complain_Subject; _log.Complain_Details = Complain_Details; _log.CompanyName = DefendentName; _log.CompanyDescription = DefendentDescription; //_log.PaymentID = PaymentID; //_log.PlacePurchaseID = PlacePurchaseID; //_log.MotiveID = Motive; _log.Payment_Text = Payment; _log.PlacePurchase_Text = PlacePurchase; _log.Motive_Text = Motive; _log.IsOversea = (IsOversea.Trim().ToUpper() == "TRUE") ? true : false; _log.OverseaAddress = OverseaAddress; _logMap.AddOrUpdate(_log); _logMap.CommitChange(); Complains_DepartmentMapDao DepTMapDao = new Complains_DepartmentMapDao(); Complains_Department _Dept = new Complains_Department(); _Dept.ComplainID = Id; _Dept.DepartmentID = Dep_ex.ID; DepTMapDao.Add(_Dept); DepTMapDao.CommitChange(); SaveUtility.SaveTransactionLog(_Item.Keygen, "Add Complain", SaveUtility.TransStatus.Create, TokenValid.ApiKey, IPAddress, "s"); //s: service result = Trueresult(new OCPB.Service.Model.Complain(_Item.Complain_Code_ID, _Item.Complain_Date.ToThaiFormate(), _Item.Complain_Time, _Item.Complain_Subject)); //} //else //{ // result = falseresult("UnAuthorized."); //} } catch (Exception ex) { SaveUtility.logError(ex); result = falseresult(ex.Message); } //finally //{ // _mapVer = null; // _Map = null; // _logMap = null; // _departMap = null; // _authenMap = null; // _cusMap = null; //} HttpContext.Current.Response.ContentType = "application/json"; HttpContext.Current.Response.Write(JsonConvert.SerializeObject(result)); HttpContext.Current.Response.End(); }