public ActionResult ChangeUsername(Account ac) { int account_id = Convert.ToInt32(Session["Account_Id"].ToString()); var account = db.Accounts.SingleOrDefault(x => x.Account_Id == account_id); if (account == null) { return(HttpNotFound()); } //ModelState.AddModelError("ConfirmPassword", System.Configuration.ConfigurationManager.AppSettings["Validate008"]); var new_username = Request.Form["New_User_Name"]; var confirm_username = Request.Form["Confirm_User_Name"]; ViewBag.New_User_Name = new_username; ViewBag.Confirm_User_Name = confirm_username; string strPattern = CustomValidate.EmailRegEx(); if (!System.Text.RegularExpressions.Regex.IsMatch(new_username, strPattern)) { ModelState.AddModelError("New_User_Name", System.Configuration.ConfigurationManager.AppSettings["Account016"]); return(View(account)); } var check_ac = db.Accounts.Where(x => x.User_Name.Equals(new_username)).SingleOrDefault(); if (check_ac != null) { ModelState.AddModelError("New_User_Name", System.Configuration.ConfigurationManager.AppSettings["Account015"]); return(View(account)); } if (new_username.ToLower() == confirm_username.ToLower()) { account.User_Name = new_username; account.Updated_Dttm = DateTime.Now; db.Entry(account).State = EntityState.Modified; db.SaveChanges(); FormsAuthentication.SetAuthCookie(new_username, true); FreebieEvent.AccountUpdateEvent(account, null, null, Permission.f_update_username_page_id); ViewBag.Type = 3; return(View("RenderStatics")); } else { ModelState.AddModelError("Confirm_User_Name", System.Configuration.ConfigurationManager.AppSettings["Account017"]); } return(View(account)); }
protected void PopupDoiMatKhau_WindowCallback(object source, DevExpress.Web.PopupWindowCallbackArgs e) { try { //Xu ly callback popup doi mat khau String strerror = ""; String result = CustomValidate.checkControlEmpty(pnPopupChangePassword, new String[] { "txtMatKhauCu", "txtMatKhauMoi", "txtXacNhanMatKhauMoi" }); if (result != null) { PopupDoiMatKhau.JSProperties["cpUpdateStatus"] = Constant.NOTIFY_FAILURE; PopupDoiMatKhau.JSProperties["cpMess"] = result; return; } HttpCookie cookie = Request.Cookies[Constant.USER_COOKIE]; if (cookie == null) { Response.Redirect("~/Login/Login.aspx"); } UsersDH ctlUser = new UsersDH(); String UserLog = Utils.Decrypt(cookie[Constant.NAME_COOKIE]); User objUser = ctlUser.validateLogin(UserLog, Utils.Encrypt(txtMatKhauCu.Text)); if (objUser == null) { PopupDoiMatKhau.JSProperties["cpUpdateStatus"] = Constant.NOTIFY_FAILURE; PopupDoiMatKhau.JSProperties["cpMess"] = "Mật khẩu cũ bạn nhập không chính xác."; return; } if (!txtMatKhauMoi.Text.Equals(txtXacNhanMatKhauMoi.Text)) { PopupDoiMatKhau.JSProperties["cpUpdateStatus"] = Constant.NOTIFY_FAILURE; PopupDoiMatKhau.JSProperties["cpMess"] = "Xác nhận mật khẩu không chính xác."; return; } ctlUser.updateUserPassword(UserLog, Utils.Encrypt(txtMatKhauMoi.Text)); PopupDoiMatKhau.JSProperties["cpUpdateStatus"] = Constant.NOTIFY_SUCCESS; PopupDoiMatKhau.JSProperties["cpMess"] = String.Format("Cập nhập mật khẩu cho tài khoản [{0}] thành công.", UserLog); return; } catch (Exception ex) { PopupDoiMatKhau.JSProperties["cpUpdateStatus"] = Constant.NOTIFY_FAILURE; PopupDoiMatKhau.JSProperties["cpMess"] = ex.Message + " " + ex.StackTrace; } }
public ActionResult UpdateAccProfile(Account account) { var selected_interests = Request.Form["selectedInterests"]; var agree_flag = Request.Form["Agree"]; ViewBag.NotAgree = ""; ViewBag.ViewProfile = "true"; int account_id = Convert.ToInt32(Session["Account_Id"].ToString()); account = db.Accounts.SingleOrDefault(x => x.Account_Id == account_id); AccountQuota account_quota = db.AccountQuotas.SingleOrDefault(x => x.Account_Id == account_id); Quota quota = new Quota(); if (account_quota == null) { account_quota = new AccountQuota(); } else { quota = account_quota.Quota; } ViewBag.Quota_Freq_Val = Convert.ToInt16(quota.Quota_Freq_Val); ViewBag.Quota_Dur_Val = Convert.ToInt16(quota.Quota_Dur_Val); Hashtable quotas = new Hashtable(); quotas["low"] = new Hashtable(); quotas["medium"] = new Hashtable(); quotas["high"] = new Hashtable(); IEnumerable <Quota> base_quotas = db.Quotas.Where(x => x.Quota_Type_Cd.Equals("B")).OrderBy(x => x.Quota_Cd); int q_count = 1; foreach (var q in base_quotas) { switch (q_count) { case 1: quotas["low"] = q; break; case 2: quotas["medium"] = q; break; case 3: quotas["high"] = q; break; default: break; } q_count += 1; } ViewBag.Quotas = quotas; string old_idcard = account.Identification_Number == null ? string.Empty : account.Identification_Number.Trim(); //Account old_account = account; if (account == null) { return(HttpNotFound()); } if (ModelState.ContainsKey("User_Name")) { ModelState["User_Name"].Errors.Clear(); } if (ModelState.ContainsKey("User_Name")) { ModelState["Password"].Errors.Clear(); } var form_vals = Request.Form; if (string.IsNullOrWhiteSpace(form_vals["First_Name"])) { ModelState.AddModelError("First_Name", System.Configuration.ConfigurationManager.AppSettings["Account003"]); } if (string.IsNullOrWhiteSpace(form_vals["Last_Name"])) { ModelState.AddModelError("Last_Name", System.Configuration.ConfigurationManager.AppSettings["Account004"]); } if (string.IsNullOrWhiteSpace(form_vals["Income_Range_Cd"])) { ModelState.AddModelError("Income_Range_Cd", System.Configuration.ConfigurationManager.AppSettings["Account025"]); } if (CustomValidate.ValidateZipcode(form_vals["ZipCode"]) != 1) { ModelState.AddModelError("ZipCode", System.Configuration.ConfigurationManager.AppSettings["Account023"]); } account.First_Name = form_vals["First_Name"]; account.Last_Name = form_vals["Last_Name"]; if (string.IsNullOrEmpty(form_vals["Day_Of_Birth"])) { account.Day_Of_Birth = null; } else { account.Day_Of_Birth = Convert.ToByte(form_vals["Day_Of_Birth"]); } if (string.IsNullOrEmpty(form_vals["Month_Of_Birth"])) { account.Month_Of_Birth = null; } else { account.Month_Of_Birth = Convert.ToByte(form_vals["Month_Of_Birth"]); } if (string.IsNullOrEmpty(form_vals["Year_Of_Birth"])) { account.Year_Of_Birth = null; } else { account.Year_Of_Birth = Convert.ToInt16(form_vals["Year_Of_Birth"]); } account.Gender_Cd = form_vals["Gender_Cd"]; account.Marital_Status_Cd = form_vals["Marital_Status_Cd"]; bool no_child = true; if (!string.IsNullOrEmpty(form_vals["Children_Flag"])) { if (form_vals["Children_Flag"].Equals("Y")) { account.Children_Flag = "Y"; no_child = false; } else { account.Children_Flag = "N"; } } if (no_child || string.IsNullOrEmpty(form_vals["Year_Of_Birth_Child1"])) { account.Year_Of_Birth_Child1 = null; } else { account.Year_Of_Birth_Child1 = Convert.ToInt16(form_vals["Year_Of_Birth_Child1"]); } if (no_child || string.IsNullOrEmpty(form_vals["Year_Of_Birth_Child2"])) { account.Year_Of_Birth_Child2 = null; } else { account.Year_Of_Birth_Child2 = Convert.ToInt16(form_vals["Year_Of_Birth_Child2"]); } if (no_child || string.IsNullOrEmpty(form_vals["Year_Of_Birth_Child3"])) { account.Year_Of_Birth_Child3 = null; } else { account.Year_Of_Birth_Child3 = Convert.ToInt16(form_vals["Year_Of_Birth_Child3"]); } account.Income_Range_Cd = form_vals["Income_Range_Cd"]; account.Occupation_Cd = form_vals["Occupation_Cd"]; account.Education_Cd = form_vals["Education_Cd"]; account.Identification_Number = form_vals["Identification_Number"]; string idcard = form_vals["Identification_Number"] == null ? string.Empty : form_vals["Identification_Number"].Trim(); if (!string.IsNullOrEmpty(idcard)) { switch (CustomValidate.ValidateIndentification(idcard)) { case 0: ModelState.AddModelError("Identification_Number", System.Configuration.ConfigurationManager.AppSettings["Account007"]); break; case 2: ModelState.AddModelError("Identification_Number", System.Configuration.ConfigurationManager.AppSettings["Account007"]); break; case 3: ModelState.AddModelError("Identification_Number", System.Configuration.ConfigurationManager.AppSettings["Account008"]); break; default: break; } } if (!string.IsNullOrEmpty(account.Children_Flag)) { if (account.Children_Flag.Equals("Y")) { if (account.Year_Of_Birth_Child1 == null) { ModelState.AddModelError("Year_Of_Birth_Child1", System.Configuration.ConfigurationManager.AppSettings["Account021"]); } } } if (account.Day_Of_Birth == null || account.Month_Of_Birth == null || account.Year_Of_Birth == null) { ModelState.AddModelError("Day_Of_Birth", System.Configuration.ConfigurationManager.AppSettings["Account020"]); } if (account.Month_Of_Birth == 2) { if (account.Day_Of_Birth > 29) { ModelState.AddModelError("Day_Of_Birth", System.Configuration.ConfigurationManager.AppSettings["Account019"]); } else { if (!(account.Year_Of_Birth % 400 == 0 || (account.Year_Of_Birth % 100 != 0 && account.Year_Of_Birth % 4 == 0))) { if (account.Day_Of_Birth == 29) { ModelState.AddModelError("Day_Of_Birth", System.Configuration.ConfigurationManager.AppSettings["Account019"]); } } } } if (agree_flag == "true") { try { if (ModelState.IsValid) { account.Updated_Dttm = DateTime.Now; UpdateModel(account); string[] interests = new string[] { }; var aci = db.AccountInterests.Where(x => x.Account_Id.Equals(account.Account_Id)).SingleOrDefault(); bool flag = false; if (aci == null) { aci = new AccountInterest(); aci.Account_Id = account.Account_Id; flag = true; } if (selected_interests != null) { interests = selected_interests.Split(','); } aci.I01_Food_Dining = interests.Contains("I01"); aci.I02_Night_Life = interests.Contains("I02"); aci.I03_Entertainment = interests.Contains("I03"); aci.I04_Music_Movie = interests.Contains("I04"); aci.I05_Sports_Fitness = interests.Contains("I05"); aci.I06_Shopping_Fashion = interests.Contains("I06"); aci.I07_Health_Beauty = interests.Contains("I07"); aci.I08_Travel = interests.Contains("I08"); aci.I09_Pets = interests.Contains("I09"); aci.I10_Kids_Children = interests.Contains("I10"); aci.I11_Home_Living = interests.Contains("I11"); aci.I12_Finance_Investment = interests.Contains("I12"); aci.I13_Technology_Gadget = interests.Contains("I13"); aci.I14_Auto = interests.Contains("I14"); if (flag) { db.AccountInterests.Add(aci); } else { db.Entry(aci).State = EntityState.Modified; } Quota select_quota = QuotaCalculation.Calculate(account, selected_interests); AccountQuota aq = db.AccountQuotas.SingleOrDefault(x => x.Account_Id.Equals(account_id)); if (aq != null) { db.AccountQuotas.Remove(aq); db.SaveChanges(); } AccountQuota new_aq = new AccountQuota(); new_aq.Account_Id = account_id; new_aq.Quota_Cd = select_quota.Quota_Cd; db.AccountQuotas.Add(new_aq); db.SaveChanges(); if (!old_idcard.Equals(idcard)) { FreebieEvent.AccountUpdateEvent(account, idcard, "Idcard", Permission.f_update_profile_page_id); } else { FreebieEvent.AccountUpdateEvent(account, null, null, Permission.f_update_profile_page_id); } return(RedirectToAction("ViewAccProfile")); } } catch (DbEntityValidationException dbEx) { foreach (var validationErrors in dbEx.EntityValidationErrors) { foreach (var validationError in validationErrors.ValidationErrors) { Trace.TraceInformation("Property: {0} Error: {1}", validationError.PropertyName, validationError.ErrorMessage); } } } } else { ViewBag.NotAgree = System.Configuration.ConfigurationManager.AppSettings["Account006"]; } var account_interest = db.AccountInterests.Where(x => x.Account_Id.Equals(account.Account_Id)).SingleOrDefault(); if (account_interest == null) { account_interest = new AccountInterest(); } List <string> interest_arrs = load_interest(account_interest); ViewBag.InterestSelected = interest_arrs; init_dropdown(account); ViewBag.Step = 3; return(View(account)); }
public ActionResult VerifySubrNumber() { string phoneNumber = Request.Form["PhoneNumber"]; ViewBag.PhoneNumber = phoneNumber; ViewBag.Path = "../AccInfo/ViewNumber"; int result = CustomValidate.ValidateNumber(phoneNumber); ViewBag.ValidNumber = false; switch (result) { case 0: ViewBag.Type = 1; ModelState.AddModelError("PhoneNumber", System.Configuration.ConfigurationManager.AppSettings["Account010"]); return(View("AddNumber")); case 1: ViewBag.ValidNumber = true; string otp = OTPHandler.SendOTPReg(phoneNumber); ViewBag.ShowPwd = true; if (otp.Equals("limit_daily")) { string err_str = System.Configuration.ConfigurationManager.AppSettings["Otp01"]; err_str = err_str.Replace("{count}", System.Configuration.ConfigurationManager.AppSettings["OTP_ALLOW_PER_DAY_PER_NUMBER"]); ViewBag.ErrorOTP = err_str; } else { if (otp.Equals("limit_interval")) { string err_str = System.Configuration.ConfigurationManager.AppSettings["Otp02"]; err_str = err_str.Replace("{minutes}", System.Configuration.ConfigurationManager.AppSettings["INTERVAL_PERIOD_BETWEEN_OTP"]); ViewBag.ErrorOTP = err_str; } } ViewBag.OTP = otp; AddCookie("Acct", new string[] { "phone_number" }, new string[] { phoneNumber }); return(View("AddNumber")); case 2: ViewBag.Type = 2; return(View("RenderStatics")); case 3: ViewBag.Type = 2; return(View("RenderStatics")); case 4: ViewBag.Type = 2; return(View("RenderStatics")); case 5: ViewBag.Type = 2; return(View("RenderStatics")); default: ViewBag.Type = 1; return(View("AddNumber")); } }