public ActionResult RegisterTH(Customer obj) { try { ModelState.Remove("IdentityID"); if (ModelState.IsValid) { obj.IdentityID = obj.tempIden.UrlDescriptHttp(); /* * var rst = _RegisterTH(obj); * if(rst.Status == true) * { * rst.text = Url.Action("Index", "Home"); * } */ //return Json(rst,JsonRequestBehavior.AllowGet); CustomerMapDao map = new CustomerMapDao(); if (map.FindIdentityCard(obj.IdentityID).Count == 0) { //obj.IdentityID = obj.IdentValid.UrlDescriptHttp(); int ID = SaveAccount.Register(obj.IdentityID, obj.TitleID, obj.Fname, obj.Lname, obj.Sex, obj.DateOfBirthStr, obj.Address, obj.DistrictID, obj.PrefectureID, obj.ProvinceID, obj.ZipCode, obj.Tel, obj.Tel_ext, obj.Mobile, obj.Fax, obj.Email, obj.OccupationID, obj.SalaryID, obj.TypeCustomer, obj.FromApp, obj.IsOversea); CustomerMapDao _CusMap = new CustomerMapDao(); obj = _CusMap.FindById(ID); if (!string.IsNullOrEmpty(obj.Email)) { SendEmail.SendMail(obj.Email, "สํานักงานคณะกรรมการคุ้มครองผู้บริโภค ยินดีต้อนรับเข้าสู่การเป็นสมาชิก", RenderPartialViewToString("regisTemplate", obj)); //SendMail.Send(obj.Email, "สํานักงานคณะกรรมการคุ้มครองผู้บริโภค ยินดีต้อนรับเข้าสู่การเป็นสมาชิก", RenderPartialViewToString("ChangePassword", obj)); } if (!string.IsNullOrEmpty(obj.Mobile)) { //SmsLibs.SendSMS(obj.Mobile, SmsLibs.TypeMessage.register); SmsLibs.SendSMS(obj.Mobile, string.Format(SmsLibs.CallStr(SmsLibs.TypeMessage.register), obj.IdentityID, Encryption.Decrypt(obj.Password))); } 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)); } } } catch (Exception ex) { SaveUtility.logError(ex); } return(View(obj)); }
public ResultData _RegisterTH(Customer obj) { CustomerMapDao map = new CustomerMapDao(); if (map.FindIdentityCard(obj.IdentityID).Count == 0) { //obj.IdentityID = obj.IdentValid.UrlDescriptHttp(); int ID = SaveAccount.Register(obj.IdentityID, obj.TitleID, obj.Fname, obj.Lname, obj.Sex, obj.DateOfBirthStr, obj.Address, obj.DistrictID, obj.PrefectureID, obj.ProvinceID, obj.ZipCode, obj.Tel, obj.Tel_ext, obj.Mobile, obj.Fax, obj.Email, obj.OccupationID, obj.SalaryID, obj.TypeCustomer, obj.FromApp, obj.IsOversea); CustomerMapDao _CusMap = new CustomerMapDao(); obj = _CusMap.FindById(ID); if (!string.IsNullOrEmpty(obj.Email)) { string filePath = Path.Combine(HttpRuntime.AppDomainAppPath, "Templates/regisTemplate.cshtml"); string html = System.IO.File.ReadAllText(filePath); SendEmail.SendMail(obj.Email, "สํานักงานคณะกรรมการคุ้มครองผู้บริโภค ยินดีต้อนรับเข้าสู่การเป็นสมาชิก", string.Format(html, obj.FullNameStr, obj.IdentityID, Encryption.Decrypt(obj.Password))); if (!string.IsNullOrEmpty(obj.Mobile)) { //SmsLibs.SendSMS(obj.Mobile, SmsLibs.TypeMessage.register); SmsLibs.SendSMS(obj.Mobile, string.Format(SmsLibs.CallStr(SmsLibs.TypeMessage.register), obj.IdentityID, Encryption.Decrypt(obj.Password))); } //SendEmail.SendMail(obj.Email, "สํานักงานคณะกรรมการคุ้มครองผู้บริโภค ยินดีต้อนรับเข้าสู่การเป็นสมาชิก", RenderPartialViewToString("regisTemplate", obj)); } return(new ResultData() { Status = true }); } else { return(new ResultData() { Status = false, text = Resources.Message.MsgDuplicate }); } }