public ActionResult ManagePassword(string s) { string oldPass = Request.Form["oldPass"]; string newPass = Request.Form["newPass"]; string confirmPass = Request.Form["confirmPass"]; if (!System.Text.RegularExpressions.Regex.IsMatch(newPass, "^(?=.*[a-z])(?=.*[A-Z])(?=.*\\d)[a-zA-Z\\d]{8,}$")) { Session["Error"] = "رمز عبور میبایست به طول ۸ و شامل حروف کوچک، بزرگ و اعداد باشد."; return(RedirectToAction("ManagePassword", "Account")); } if (!newPass.Equals(confirmPass)) { Session["Error"] = "رمزعبور جدید با تکرار آن مطابقت ندارد"; return(RedirectToAction("ManagePassword", "Account")); } User user = Utilities.CommonUtilities.GetUser(); if (!user.Password.Equals(oldPass)) { Session["Error"] = "رمز عبور فعلی اشتباه است."; return(RedirectToAction("ManagePassword", "Account")); } PoliceContext ctn = ContextCreator.GetInstance().GetContext(); User userUpdate = ctn.Users.FirstOrDefault(u => u.Username.Equals(user.Username)); if (userUpdate != null) { userUpdate.Password = newPass; } ctn.SaveChanges(); Session["Information"] = "رمز با موفقیت تغییر کرد."; return(RedirectToAction("MessagePage", "Default")); }
public object Clone() { PoliceContext contex = ContextCreator.GetInstance().GetContext(); DbSet set = contex.Set(this.GetType()); AbstractEntity clonedEntity = set.Find(this.Id) as AbstractEntity; contex.Entry(clonedEntity).State = EntityState.Detached; if (clonedEntity == null) { //TODO //throw new UserInterfaceException(27701, String.Format("امکان کپی کردن {0} با شناسه ی {1} وجود ندارد، لطفا با بخش پشتیبانی تماس بگیرید.", this.GetType(), this.ID)); throw new Exception("----abstract entity failed! ----"); } clonedEntity.Id = System.Guid.NewGuid().GetHashCode(); return(clonedEntity); }