public ActionResult DeleteConfirmed(int id) { FundRaisers fundRaiser = db.FundRaisers.Find(id); db.FundRaisers.Remove(fundRaiser); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "FundRaiserId,FirstName,LastName,Email,Password,ConfirmPassword")] FundRaisers fundRaiser) { if (ModelState.IsValid) { db.Entry(fundRaiser).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(fundRaiser)); }
public ActionResult SignIn([Bind(Include = "FundRaisersId,FirstName,LastName,Email,Password,ConfirmPassword")] FundRaisers FundRaisers) { if (ModelState.IsValid) { // If() db.FundRaisers.Add(FundRaisers); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(FundRaisers)); }
// GET: FundRaisers/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } FundRaisers fundRaiser = db.FundRaisers.Find(id); if (fundRaiser == null) { return(HttpNotFound()); } return(View(fundRaiser)); }
public ActionResult Create([Bind(Include = "FundRaisersId,FirstName,LastName,Email,Password,ConfirmPassword")] FundRaisers FundRaisers) { if (ModelState.IsValid) { var salt = Crypto.GenerateSalt(); var saltedPassword = FundRaisers.Password + salt; var hashedPassword = Crypto.HashPassword(saltedPassword); FundRaisers.Password = hashedPassword; FundRaisers.ConfirmPassword = hashedPassword; db.FundRaisers.Add(FundRaisers); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(FundRaisers)); }
public ActionResult ChangePassword(Models.RegisterViewModel updatedUser) { // Get the current user's emailAddress to find the current user in the database. string emailAddress = User.Identity.GetUserName(); FundRaisers currentUser = db.FundRaisers.FirstOrDefault(u => u.Email == emailAddress); // Only change the user's password in the database if the password field is not left blank. if (updatedUser.Password != "") { string newPassword = Crypto.HashPassword(updatedUser.Password); currentUser.Password = newPassword; currentUser.ConfirmPassword = newPassword; } db.Entry(currentUser).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index", "Home")); }
public ActionResult Create([Bind(Include = "FundRaisersId,FirstName,LastName,Email,Password,ConfirmPassword,verificationToken,verified")] FundRaisers FundRaisers) { if (ModelState.IsValid) { var hashedPassword = Crypto.HashPassword(FundRaisers.Password); FundRaisers.Password = hashedPassword; FundRaisers.ConfirmPassword = hashedPassword; db.FundRaisers.Add(FundRaisers); FundRaisers.verified = false; FundRaisers.verificationToken = Guid.NewGuid().ToString(); db.SaveChanges(); // this.confirmationEmailSend(FundRaisers.Email, FundRaisers.verificationToken); return(View("CheckEmail")); // HttpContext.Session.Add("fundRaiser", FundRaisers); } else { return(View("FundRaisers")); } }
public ActionResult SignIn([Bind(Include = "Email,Password")] AccountLoginViewModel userTryingToLogin) { if (userTryingToLogin != null & ModelState.IsValid) { FundRaisers doesUserExist = db.FundRaisers.FirstOrDefault(s => s.Email.Equals(userTryingToLogin.Email)); try { if (!doesUserExist.verified) { ModelState.AddModelError("doesUserExist", "Email Not verified. Please check your email confirmation"); return(View("SignInFailure")); } bool a = Crypto.VerifyHashedPassword(doesUserExist.Password, userTryingToLogin.Password); if (a == true) { // creating authetication ticket FormsAuthentication.SetAuthCookie(userTryingToLogin.Email, false); Session["userId"] = doesUserExist.FundRaisersId; return(RedirectToAction("Index", "Home")); } else { @ViewBag.Message = "Error.Ivalid login."; return(View("SignInFailure")); } } catch { @ViewBag.Message = "Error.Ivalid login."; return(View("SignInFailure")); } } ModelState.AddModelError("UserDoesNotExist", "Username or Password is Incorrect! Please try Again!!"); return(View(userTryingToLogin)); }