public ActionResult EditTeacher([Bind(Include = "TeacherID,Name,Email,Mobile,Faculty,Department,Password")] Teacher teacher) { Teacher tcr = db.Teacher.Find(teacher.TeacherID); db.Entry(tcr).State = EntityState.Detached; if (tcr.PasswordChanged == true) { EncryptionDectryption sc = new EncryptionDectryption(); teacher.Password = sc.Encryptdata(teacher.Password); teacher.PasswordChanged = true; } if (teacher.Password.Equals(tcr.Password)) { if (ModelState.IsValid) { db.Entry(teacher).State = EntityState.Modified; db.SaveChanges(); } return(RedirectToAction("TeachersList", "Admin")); } else { ViewBag.Message = "Please Put the correct password"; return(View()); } }
public ActionResult Index(string usertype, string username, string password) { try { username = username.Replace(" ", String.Empty); password = password.Replace(" ", String.Empty); } catch (NullReferenceException e) { } if (username != null && password != null) { if (usertype.Equals("admin")) { string email = "*****@*****.**"; Login aLogin = new Login(); Boolean ch = aLogin.LoginCheck(username, password); if (ch == true) { return(RedirectToAction("Index", "Admin", new{ username = username, email = email })); } } else if (usertype.Equals("teacher")) { ViewBag.username = username; ViewBag.password = password; Login aLogin = new Login(); Teacher teacher = aLogin.TeacherLoginCheck(username); if (teacher.PasswordChanged == true) { password = new EncryptionDectryption().Encryptdata(password); } if (teacher.Email == username && teacher.Password == password) { HttpContext.Session["teacher"] = teacher; return(RedirectToAction("Index", "Teacher")); } } } return(View()); }
public ActionResult ChangePassword(int? TeacherID, String oldpassword, String newpassword, String retypenewpassword) { Teacher teacher = db.Teacher.Find(TeacherID); if (newpassword.Equals(retypenewpassword)) { if (teacher.PasswordChanged == true) { oldpassword = new EncryptionDectryption().Encryptdata(oldpassword); } if(teacher.Password.Equals(oldpassword)){ teacher.Password = new EncryptionDectryption().Encryptdata(newpassword); teacher.PasswordChanged = true; db.Entry(teacher).State = EntityState.Modified; db.SaveChanges(); ViewBag.Message = "Successfully password changed"; return RedirectToAction("index", "Teacher"); } else { ViewBag.Message = "Invalid Old Password..!"; return View(teacher); } } else { ViewBag.Message = "Miss Match new Password..!"; return View(teacher); } }