public static PasswordChangeStatus ChangePassword(int OrcaUserID, PasswordChange passwordChange) { OrcaContext db = new OrcaContext(); OrcaPassword userPasswordQuery = null; // get the password from Passwords db table try { //OrcaPassword userPasswordQuery = (from user in db.OrcaPasswords // where user.OrcaUserID == OrcaUserID // select user).First(); userPasswordQuery = db.OrcaPasswords.AsQueryable().First(user => user.OrcaUserID == OrcaUserID); } catch (Exception)// if the OrcaUserID could not be found, return INVALID_USER { return(PasswordChangeStatus.INVALID_USER); } // make sure the proper original password was entered if (userPasswordQuery.Password == passwordChange.CurrentPassword) { // change the password userPasswordQuery.Password = passwordChange.Password; // update the database db.Entry(userPasswordQuery).State = EntityState.Modified; db.SaveChanges(); return(PasswordChangeStatus.SUCCESS); } return(PasswordChangeStatus.INVALID_PASSWORD); }
public ActionResult DeleteConfirmed(int id) { OrcaPassword orcaPassword = db.OrcaPasswords.Find(id); db.OrcaPasswords.Remove(orcaPassword); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "OrcaUserID,Password")] OrcaPassword orcaPassword) { if (ModelState.IsValid) { db.Entry(orcaPassword).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.OrcaUserID = new SelectList(db.OrcaUsers, "OrcaUserID", "OrcaUserName", orcaPassword.OrcaUserID); return(View(orcaPassword)); }
public ActionResult Create([Bind(Include = "OrcaUserID,Password")] OrcaPassword orcaPassword) { if (ModelState.IsValid) { db.OrcaPasswords.Add(orcaPassword); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.OrcaUserID = new SelectList(db.OrcaUsers, "OrcaUserID", "OrcaUserName", orcaPassword.OrcaUserID); return(View(orcaPassword)); }
// GET: zzzTESTinCASEOrcaPasswords/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } OrcaPassword orcaPassword = db.OrcaPasswords.Find(id); if (orcaPassword == null) { return(HttpNotFound()); } return(View(orcaPassword)); }
// GET: zzzTESTinCASEOrcaPasswords/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } OrcaPassword orcaPassword = db.OrcaPasswords.Find(id); if (orcaPassword == null) { return(HttpNotFound()); } ViewBag.OrcaUserID = new SelectList(db.OrcaUsers, "OrcaUserID", "OrcaUserName", orcaPassword.OrcaUserID); return(View(orcaPassword)); }